Worklight ant tasks for deployment - deployment

I am using this documentation.
It tells me to do a ant target like this.
<target name="Deploy App">
<app-deployer deployable="${build.apps.dir}/app.wlapp"
worklightServerHost="http://${customConfig.worklightServer.host}:${customConfig.worklightServer.port}/${customConfig.runtime}"
userName="admin" password="admin" />
</target>
However when I run this target it tells me that app-deployer task is deprecated and I should use something else.
The entire message is below:
[app-deployer] The Ant task <app-deployer> is no longer supported.
[app-deployer] You need to replace this invocation with an invocation of the <wladm> Ant task, like this:
[app-deployer] <taskdef resource="com/worklight/ant/deployers/antlib.xml">
[app-deployer] <classpath>
[app-deployer] <pathelement location="buildTools\buildJars\worklight-ant-deployer.jar"/>
[app-deployer] </classpath>
[app-deployer] </taskdef>
[app-deployer] <wladm url="** URL of Worklight administration services **" user="admin" password="admin">
[app-deployer] <deploy-app runtime="** project runtime name **" file="app.wlapp"/>
[app-deployer] </wladm>
[app-deployer] where values between ** markers are to be filled in.
The version of the worklight ant deployer I'm using is this.
[echo] Worklight Ant task version 6.2.0.00.20140613-0730
Nevertheless, when I create a target with wladm it tells me that
Problem: failed to create task or type wladm
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.

The most frequent causes for said error message "failed to create task or type wladm" are:
The <taskdef> has not been executed at this point, in the current Ant script. You may have it in a different target, that is not executed before the current target. The fix is to list it in a common initialization target, or outside of any targets, directory under <project>.
The <taskdef> refers to a nonexistent file or to an older version of worklight-ant-deployer.jar than 6.2.0.
The <taskdef> loads resource="com/worklight/ant/defaults.properties", but in 6.2 it needs to load resource="com/worklight/ant/deployers/antlib.xml".

Not exactly an answer to your question but if you do not need Ant, you can use wladm in command line. See doc at https://www-01.ibm.com/support/knowledgecenter/SSZH4A_6.2.0/com.ibm.worklight.appadmin.doc/admin/r_wladm_program_app_commands.html
The wladm command is in [WorklightInstallDir]/shortcuts

Related

Ant Build: "Failed to create task, Cause: name is undefined"

I get this error when I try running an Ant Build:
Problem: failed to create task or type http://com.ibm.adapter:createProject
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
No types or tasks have been defined in this namespace yet
I checked the Runtime JRE (Run in the same JRE as the workspace).
It seems like it can't find the right jar, so I added it (com.ibm.adapter.command) in the Ant Home Entries, but it doesn't work anyway.
Here is the script (even if there shouldn't be problems in this because in another computers worka, I think the problem is only about RAD configuration)
<project default="CreateRigaVariazioneSostituzione" name="/EssigIntegrazione/RigaVariazioneSostituzione.xml" xmlns:adapter="http://com.ibm.adapter">
<property name="debug" value="true"/>
<property name="projCpy2Java" value="EssigIntegrazione"/>
<target name="CreateRigaVariazioneSostituzione">
<adapter:createProject projectName="${projCpy2Java}" projectType="Java" sourceFolder="/src"/>
....
</target>
</project>
Do you know how to fix this?
Install J2C Connector from IBM Installation Manager

Problem: failed to create task or type projectImport

I'm quite new with ANT to build an Eclipse (Oxygen) project. I'm using existing build.xml file which previously written in RAD environment.
Here is my build.xml task;
<foreach
list="${projects.name}"
param="project"
target="import-project" />
<target name="import-project">
<!-- Debug information -->
<echo message="project.name=${project}" />
<echo message="projectLocation=${rad.workspace}\${project}" />
<projectImport
projectName="${project}"
projectLocation="${rad.workspace}\${project}" />
<echo message="projectImport ${project} done" />
</target>
And here is the error
BUILD FAILED
Problem: failed to create task or type projectImport
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
I don't know whether projectImport is available in Eclipse or only in IBM RAD. But if the task is available in Eclipse, do you have any idea why task is failed and if the task only available in IBM RAD, what are the tasks available for me to import project to current workspace.
Thanks
projectImport is IBM RAD only. I don't know of any standard Eclipse equivalent.
Standard Eclipse only provides a very small number of Ant tasks and they all start with eclipse.. See here for the Eclipse tasks list.

How add antlib declaration to project in eclipse?

I have created project named "antt" to test ant with Migration tool from eclipse.
I have created java project in eclipse and try run "test" from there.
"test" in build.xml:
<!-- Test out deploy and retrieve verbs for package 'mypkg' -->
<target name="test">
<!-- Upload the contents of the "mypkg" package -->
<sf:deploy username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" deployRoot="mypkg" rollbackOnError="true"/>
<mkdir dir="retrieveOutput"/>
<!-- Retrieve the contents into another directory -->
<sf:retrieve username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" retrieveTarget="unpackaged" packageNames="MyPkg"/>
</target>
Error:
Buildfile: C:\SF\workspacenew\antt\build.xml test:
BUILD FAILED C:\SF\workspacenew\antt\build.xml:19: Problem: failed to create task or type antlib:com.salesforce:deploy Cause: The name is undefined. Action: Check the spelling. Action: Check that any custom tasks/types have been declared. Action: Check that any <presetdef>/<macrodef> declarations have taken place. No types or tasks have been defined in this namespace yet
This appears to be an antlib declaration. Action: Check that the implementing library exists in one of:
-C:\eclipse\plugins\org.apache.ant_1.8.4.v201303080030\lib
-C:\Users\User\.ant\lib
-a directory added on the command line with the -lib argument
Total time: 560 milliseconds
Refer to my answer over here,
Create a lib directory in the root of your project and place the maven-ant-tasks.jar file inside it.
Include the import statement in your build.xml
<path id="maven-ant-tasks.classpath" path="lib/maven-ant-tasks-2.1.3.jar" />
<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="antlib:org.apache.maven.artifact.ant" classpathref="maven-ant-tasks.classpath" />
Hope this helps.

Unable to deploy JavaFX applicaiton with external libraries in a JAR

I'm developing a JavaFX application in Eclipse. The app has external libraries, like log4j and others and runs perfectly from Eclipse. I've tried deploying it from Eclipse as a Runnable jar through the Eclipse built-in feature, and it runs well on some computers, while on others it would give me an obscure Undefined Link error. After digging around it seems JavaFX needs to be specially packaged either through an ANT script or through the javafxpackager application.
For the life of me I can't seem to deploy a runnable jar through either of those methods. Trying either of those methods, I get an Exception. Things I've tried:
Build the JavaFX application through an ANT script, below is a snippet of the relevant parts of the build script
<path id="classpath">
<fileset dir="${lib.dir}" includes="**/*.jar"/>
<fileset dir="${javafx.sdk.path}/jre/lib" includes="jfxrt.jar"/>
</path>
<target name="compile" depends="clean">
<echo>Compiling the source</echo>
<mkdir dir="${classes.dir}"/>
<!-- Copy over the misc files into the classes dir -->
<copy todir="${classes.dir}/bundles">
<fileset dir="${src.dir}/bundles"/>
</copy>
<copy todir="${classes.dir}/css">
<fileset dir="${src.dir}/css"/>
</copy>
<copy todir="${classes.dir}/img">
<fileset dir="${src.dir}/img"/>
</copy>
<copy todir="${classes.dir}/views">
<fileset dir="${src.dir}/views"/>
</copy>
<copy todir="${classes.dir}/bundles">
<fileset dir="${src.dir}/bundles"/>
</copy>
<copy file="${src.dir}/log4j2.xml" todir="${classes.dir}"/>
<javac target="1.7" srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath" debug="on">
</javac>
</target>
<target name="jar" depends="compile">
<echo>Creating the main jar file</echo>
<mkdir dir="${distro.dir}" />
<fx:jar destfile="${distro.dir}/main.jar" verbose="true">
<fx:platform javafx="2.1+" j2se="7.0"/>
<fx:application mainClass="${main.class}"/>
<!-- What to include into result jar file?
Everything in the build tree-->
<fileset dir="${classes.dir}"/>
<!-- Define what auxilary resources are needed
These files will go into the manifest file,
where the classpath is defined -->
<fx:resources>
<fx:fileset dir="${distro.dir}" includes="main.jar"/>
<fx:fileset dir="." includes="${lib.dir}/**" type="jar"/>
<fx:fileset dir="." includes="."/>
</fx:resources>
<!-- Make some updates to the Manifest file -->
<manifest>
<attribute name="Implementation-Vendor" value="${app.vendor}"/>
<attribute name="Implementation-Title" value="${app.name}"/>
<attribute name="Class-Path" value="${lib.dir}"/>
<attribute name="Implementation-Version" value="1.0"/>
</manifest>
</fx:jar>
</target>
Compiling/generating the jar through the ant script, I get a window pop up for half a second and "Exception in Application start method" in the console, with no stack trace. I've tried runnning java with the -XX:-OmitStackTraceInFastThrow flag, but it still won't give me a stack trace.
Running through javafxpackager gives the following error:
RenderJob.run: internal exception
java.lang.UnsatisfiedLinkError: com.sun.prism.d3d.D3DContext.nSetBlendEnabled(JZ
Z)I
at com.sun.prism.d3d.D3DContext.nSetBlendEnabled(Native Method)
at com.sun.prism.d3d.D3DContext.initState(D3DContext.java:84)
at com.sun.prism.d3d.D3DResourceFactory.(D3DResourceFactory.java:5
7)
at com.sun.prism.d3d.D3DPipeline.createResourceFactory(D3DPipeline.java:
147)
at com.sun.prism.d3d.D3DPipeline.getD3DResourceFactory(D3DPipeline.java:
153)
at com.sun.prism.d3d.D3DPipeline.findDefaultResourceFactory(D3DPipeline.
java:179)
at com.sun.prism.d3d.D3DPipeline.getDefaultResourceFactory(D3DPipeline.j
ava:201)
at com.sun.prism.GraphicsPipeline.getDefaultResourceFactory(GraphicsPipe
line.java:97)
at com.sun.javafx.tk.quantum.QuantumRenderer$3.run(QuantumRenderer.java:
143)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:47
1)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304)
at com.sun.prism.render.RenderJob.run(RenderJob.java:37)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:615)
at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(Quantu
mRenderer.java:98)
at java.lang.Thread.run(Thread.java:724)
You can deploy your application using javafxpackager. If you deploy a self contained application, the Java Runtime Environment will be bundled with your application and it will run on any machine whether the right version of Java is installed or not.
(You should have javafxpackager in your jdk directory under the bin folder.)
Look for your compiled files (.class) in your eclipse workspace folder. They should be in the bin directory.
Create a createjar folder and inside it create a classes and a out folder. Copy all of your .class files in the classes folder. Also include in the classes folder all jar needed by your application.
Now on the command line go inside the createjar directory and run this command :
"C:\path\to\jdk\jdk1.7.0_25\bin\javafxpackager.exe" -createjar -appclass package.MainClass -srcdir classes -outdir out -outfile NameOfYourJar -classpath "" -v
This should create a runnable jar in the out directory. You will need it for the next step.
Now create a deploy folder alongside the createjar folder.
Inside the deploy folder make to other directories dist and packages.
In the dist folder copy your freshly created jar from above plus all the dependencies/ressources it will need.
Go back on the command line (if you ever left it) and go in the deploy directory. Run the following command from there :
"C:\path\to\jdk\jdk1.7.0_25\bin\javafxpackager.exe" -deploy -native -outdir packages -outfile NameOfYourApp -srcdir dist -srcfiles NameOfYourJar.jar -appclass package.MainClass -name "Name of You Application" -title "Title of your application"
Once it is done it should have created all you need to deploy your app including native .exe file to run on Windows platform. This is the self contained application ! To be able to run it you need to go into bundles\NameOfYourApp\app and paste here all dependencies/ressource your app needs.
At last, double click on YourApp.exe and it should run even on machines without Java installed.
With ant files you have two main options: <fx:jar> and <fx:deploy>. The former just produces a jar that allows you to refer to your dependencies if they are in the same file as the jar. You can unpack the jar and look at the MANIFEST file produced to see how they are added to the javafx classpath.
<fx:deploy> allows you to pull in dependencies, but requires that you build a platform-specific installer. It can't be done using a jar. Apparently NetBeans allows you to create a stand-alone jar but I have not tested with that.
you do not package javafxrt.jar with your app
e(fx)clipse would have produced the ant-script for your if you use it

Ivy fails to resolve a dependency, unable to find cause

While using ivy:retrieve, it fails to resolve the dependency that should be downloaded. The output looks like this:
Buildfile: C:\Users\Simon\workspace\apollo\build.xml
init:
resolve:
BUILD FAILED
C:\Users\Simon\workspace\apollo\build.xml:42: Problem: failed to create task or type antlib:org.apache.ivy.ant:retrieve
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
No types or tasks have been defined in this namespace yet
This appears to be an antlib declaration.
Action: Check that the implementing library exists in one of:
-C:\Users\Simon\eclipse\plugins\org.apache.ant_1.8.2.v20120109-1030\lib
-C:\Users\Simon\.ant\lib
-a directory added on the command line with the -lib argument
Total time: 348 milliseconds
The relevant section of the build.xml looks like so:
<target name="resolve" depends="init">
<ivy:retrieve pattern="${lib}/[artifact]-[revision].[ext]" sync="true" />
</target>
Here is also a list of what it should be downloading (from the build.xml)
<target name="doc" depends="build">
<javadoc sourcepath="${src}" classpathref="libraries" access="private" destdir="${doc}" windowtitle="Apollo">
<doclet name="org.jboss.apiviz.APIviz" pathref="libraries">
<param name="-sourceclasspath" value="${bin}" />
<param name="-author" />
<param name="-version" />
<param name="-use" />
<param name="-nopackagediagram" />
</doclet>
<doctitle><![CDATA[<h1>Apollo</h1>]]></doctitle>
<link href="http://download.oracle.com/javase/6/docs/api/" />
<link href="http://docs.jboss.org/netty/3.2/api/" />
<link href="http://guava-libraries.googlecode.com/svn/trunk/javadoc/" />
<link href="http://www.junit.org/apidocs/" />
<link href="http://commons.apache.org/compress/apidocs/" />
<link href="http://jruby.org/apidocs/" />
</javadoc>
</target>
ANT cannot find the ivy jar. Needs to be downloaded, extracted, and the ivy-x.y.z.jar placed into one of the following locations:
$ANT_HOME/lib
$HOME/.ant/lib
Enabling ivy
Ivy is packaged as an antlib, so to enable it you need to do the following
1)
Declare the ivy namespace at the top of the build file
<project ..... xmlns:ivy="antlib:org.apache.ivy.ant">
2)
Include the ivy jar in one of the ant library directories
Your error message indictates some of the possible locations for antlibs:
This appears to be an antlib declaration.
Action: Check that the implementing library exists in one of:
-C:\Users\Simon\eclipse\plugins\org.apache.ant_1.8.2.v20120109-1030\lib
-C:\Users\Simon\.ant\lib
-a directory added on the command line with the -lib argument
Note:
The beauty of an antlib is that you don't need to perform the taskdef (It's optional if you want to place the ivy jar in a non-standard location)
How to bootstrap a build
Even though ivy is an ANT sub-project, for some inexplicable reason ivy is not packaged with ANT....
I normally include the following target in my build files to setup a new environment:
<target name="bootstrap" description="Used to install the ivy task jar">
<mkdir dir="${user.home}/.ant/lib"/>
<get dest="${user.home}/.ant/lib/ivy.jar" src="http://search.maven.org/remotecontent?filepath=org/apache/ivy/ivy/2.2.0/ivy-2.2.0.jar"/>
</target>
It downloads the ivy jar from Maven Central.
Since all other ANT tasks can subsequently be downloaded using ivy, few people object to this little piece of ugliness at the top of the build file.
If you can't put the ivy libs in the classpath for ant you will need to define it yourself:
<path id="ivy.lib.path">
<fileset dir="path/to/dir/with/ivy/jar" includes="*.jar"/>
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml"
uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
This bit is missing from the getting started tutorial, but listed here: http://ant.apache.org/ivy/history/2.2.0/ant.html
When you Run Ant task, in the classpath ensure that ivy.jar is there. In the eclipse -> Run As-> Ant Build -> Edit configuration -> Classpath tab. Even though Eclipse would have the ivy.jar in the ANT Home, for some reason it's not called.
I had a similar problem on MacOSX (10.11.6 El Capitan). I installed ant and Ivy with the Brew package manager.
One additional way is to define it manually using the -lib option, e.g.:
ant clean compile -lib /usr/local/Cellar/ivy/2.4.0/libexec/ivy-2.4.0.jar
Even after adding ivy jar to the ant lib, it was not being picked up. Selecting the ANT_HOME again in Preferences->Ant->Runtime will cause the lib dir to be refreshed, and any libraries you have added there to be taken up.