I'm trying to deploy adapters & WLAPP using ANT to a server with a protected Worklight console (form-based).
Here's my ANT task:
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="help">
<taskdef resource="com/worklight/ant/defaults.properties">
<classpath>
<pathelement location="worklight-ant.jar"/>
</classpath>
</taskdef>
<target name="test">
<adapter-deployer deployable="Test.adapter" worklightServerHost="http://testserver/MyApp" userName="username" password="password" />
</target>
</project>
When I run it I got this error message:
adapter-deployer doesn't support the "userName" attribute
The server is running Worklight 6.0
Any ideas?
revised answer: What you're looking to do is not possible in Worklight 6.0.0.0. It was added as part of the Worklight 6.0.0.1 fix pack release via:
PM98052 You cannot deploy with ANT tasks when security is enabled for
the Application Center or Console
Make sure you are using the latest Worklight 6.0.0.x fix pack, currently: Worklight 6.0.0.2 Developer Edition (if you are an IBM customer or business partner, you can get it from Fix Central).
Related
I'm using WL 6.2.0.1 and one of our projects contains a Java files inside the WL server directory.
When I do the build for war file through eclipse I follow the following steps:
1- Right click on the project name > Build Project.
2- Right click on the project name > IBM Mobile Application Platform Pattern > Build Worklight EAR file.
Which generates to me the war file and inside it I see the java files.
When I switched to use ANT script to build the WAR file, I can't see the Java files anymore inside the war file:
ANT script:
<?xml version="1.0" encoding="UTF-8"?>
<project name="MobileApp" default="package" basedir="../">
<property name="WL_PATH" value="./buildscripts"/>
<property name="project.name" value="MobileApp"/>
<taskdef resource="com/worklight/ant/defaults.properties">
<classpath>
<pathelement location="${WL_PATH}/worklight-ant6.2/worklight-ant-builder.jar"/>
</classpath>
</taskdef>
<target name="WAR_CREATE">
<war-builder projectfolder="${basedir}/temp/source/${project.name}"
destinationfolder="bin/war"
warfile="bin/MobileApp.war"
classesFolder="classes-folder"/>
</target>
</project>
I'm not sure if I need to add the Java element to the script so it will compile the Java files. but I tried to add <Javac> but didn't work.
I referred to the following URL : https://ant.apache.org/manual/Tasks/javac.html. But Didn't know which one to use.
Any help thanks.
XML
<?xml version="1.0" encoding="UTF-8"?>
<project name="myProject" default="all">
<taskdef resource="com/worklight/ant/defaults.properties">
<classpath>
<pathelement location="cli_install_dir/public/worklight-ant-builder.jar"/>
</classpath>
</taskdef>
<path id="server-classpath">
<fileset dir="..\jars\Resources" includes="worklight-jee-library.jar" />
<fileset dir="..\jars\Resources\dev" includes="**/*.jar" />
</path>
<mkdir dir="bin\classes"/>
<javac
srcdir="${worklight.repositary}\${proj.brcname}\server\java"
classpathref="server-classpath"
destdir="bin\classes"
verbose="true"
includeantruntime="false"
target="1.6"
/>
<target name="all">
<war-builder projectfolder="."
destinationfolder="bin/war"
warfile="bin/project.war"
classesFolder="bin\classes"/>
</target>
</project>
The Above is the XML is used to Create a War file along with java classes.
Note :
In the places of dir , location and srcdir replace the content directory with your Locations.
Unlike when using the Studio which automatically compiles any Java files that reside under the server\ folder, this does not happen when using the Ant task scripts.
You must first compile these files and point to the folder containing the resulting .class files. This pointing is done in the classesFolder attribute in the Ant task script.
For further elaboration see this answer by me: https://stackoverflow.com/a/30302415/1530814
I am trying to build the project .war file with Ant in MobileFirst Platform 6.3.
my build.xml has the following:
<?xml version="1.0" encoding="UTF-8"?>
<project name="myProject" default="all">
<taskdef resource="com/worklight/ant/defaults.properties">
<classpath>
<pathelement location="/Applications/IBM/Worklight-CLI/public/worklight-ant-builder.jar"/>
</classpath>
</taskdef>
<target name="all">
<war-builder projectfolder="."
destinationfolder="bin/war"
warfile="bin/project.war"
classesFolder="classes-folder"/>
</target>
</project>
When I execute the Ant script it throws the following error:
[taskdef] Could not load definitions from resource
com/worklight/ant/defaults.properties. It could not be found.
You mention that you are using MFP 6.3, but in your XML you are pointing to "Worklight-CLI", which is not MFP 6.3, but 6.2 or older. Are you sure you're really using MFP 6.3?
It is also referring to the CLI. Are you certain you intend to use the CLI? No where in your question do you mention the CLI...
Verify you have installed the correct version of what you intend to use
Once you've installed the correct version, change the location attribute to:
location="/Applications/IBM/MobileFirst-CLI/mobilefirst-cli/node_modules/generator-worklight-server/ant-tools/worklight-ant-builder.jar"
I've upgraded my worklight server from v6.0 to v6.1.
The target environment is Liberty and Oracle database.
I've build a war for v6.1 and try to deploy it.
it fails with following error message:
[taskdef] Could not load definitions from resource com/worklight/ant/defaults.properties. It could not be found.
The name of ANT jars have changed. So i had to take the new want named "worklight-ant-deployer.jar" instead of "worklight-ant.jar" in my xml config file.
<taskdef resource="com/worklight/ant/defaults.properties">
<classpath>
<fileset dir="${worklight.server.install.dir}/WorklightServer">
<include name="worklight-ant-deployer.jar"/>
</fileset>
</classpath>
</taskdef>
I'm using Ant to deploy my application to the production application server(WebSphere).
I use the sample configuration file located in the ${WORKLIGHT_INSTALL_DIR}\configuration-samples folder. the configuration file is marked as suitable for Websphere liberty and Apache derby.
On the configuration sections i change the value (and only this value according with the documentation IBM) of the path element tag (below the code reported).
<taskdef resource="com/worklight/ant/defaults.properties">
<classpath>
<pathelement location="C:\workspace\jQueryMobileApplication\bin\jQueryMobileApplication.war"/>
</classpath>
Setting as location my application war's path. The build.xml file is located in the same folder of my project's war file.
When i type the command :
ant -f <filename>.xml
i get this exception:
Buildfile: C:\IBM\WorklightSRV\WorklightServer\configure-liberty-derby.xml
[taskdef] Could not load definitions from resource com/worklight/ant/defaults.properties. It could not be found.
I'm a newbie with Worklight development(and also with Ant Deployment), so i appreciate any help even if this may be a trivial question.
The classpath is for the worklight-ant.jar to define the tasks to ant
ex.
<taskdef resource="com/worklight/ant/defaults.properties">
<classpath>
<pathelement location="./lib/worklight-ant.jar" />
</classpath>
</taskdef>
After the ant tasks are loaded you can use one of the worklight ant tasks to do your commands
ex.
<echo>Export war file</echo>
<war-builder projectfolder="./<ProjectDirectory>" destinationfolder="bin/war" warfile="bin/Application.war.${env}" classesFolder="<ProjectDirectory>/bin/classes" />
From what i know this will create the war for you but you will have to deploy it manually.
I have a wsdl and I'd like to generate jax-ws type Java source from it using IBM Websphere version of wsimport. How can I do this in an easy way? wsimport.bat references com.ibm.ws.jaxws.tools.WsImport to do the code generation.
I solved the problem by calling wsimport directly. Just make sure websphereHome is set to the websphere home folder on your machine. Then genDir is the folder where you want the files to be generated to. Finally, wsdlFile is the path to the wsdl used for generation.
task generateWSDL2Java(type:Exec) {
doFirst{
genDir.mkdirs()
}
cmd = websphereHome + '/bin/wsimport.bat -keep -d '+genDir+' '+wsdlFile
commandLine = ['cmd', '/K', cmd]
}
Here's a simple Ant script, using a WebSphere 6.1 runtime (with the WebSphere Feature Pack, which is required for JAX-WS), which I just tested:
<?xml version="1.0" encoding="UTF-8"?>
<project name="JAX-WS Client">
<property name="was.dir" value="C:\Program Files (x86)\IBM\WebSphere\AppServer"/>
<path id="jaxws.gen.classpath">
<fileset dir="${was.dir}/plugins">
<include name="*com.ibm.wsfp.main_6.1.0.jar" />
<include name="*org.apache.axis2_6.1.0.jar" />
<include name="*com.ibm.jaxws.tools_6.1.0.jar" />
<include name="*com.ibm.jaxb.tools_6.1.0.jar" />
</fileset>
<fileset file="${was.dir}/lib/j2ee.jar"/>
</path>
<!-- Ant task definition for wsimport -->
<taskdef classpathref="jaxws.gen.classpath" name="wsimport" classname="com.sun.tools.ws.ant.WsImport"/>
<target name="wsimport">
<wsimport sourcedestdir="./src" destdir="./build" debug="true" verbose="true"
keep="true" wsdl="${wsdlFile}" />
</target>
</project>
If you have RAD 8, here's the InfoCenter article which describes using the JAX-WS Ant tasks from within that. I'm not sure how other WebSphere development environments compare.
JAX-WS artifacts are portable, which means that you are not required to use IBM's tools. BTW, I think that the wsgen and wsimport tools shipped with WAS actually use code from the Sun/Oracle reference implementation.
Therefore you could use any documented solution for Gradle, even if it is not WebSphere specific.