Worklight project throwing error while uploading files to mobileFirstServer - ant

I am using ant script to deploy adapters and wlapp file over mobileFirstServer. I am using Java 7. Using the code below:
<target name="deploy-wlapp">
<taskdef resource="com/worklight/ant/deployers/antlib.xml">
<classpath>
<pathelement location="worklight-ant-deployer.jar"/>
</classpath>
</taskdef>
<wladm url="http://localhost:10080/worklightadmin" user="admin" password="admin" secure="false">
<deploy-app runtime="myTime" file="/Users/admin/Documents/workspace/myTime/bin/myTime-iOSnative- 1.0.wlapp"/>
</wladm>
</target>
<target name="deploy-adapter">
<taskdef resource="com/worklight/ant/deployers/antlib.xml">
<classpath>
<pathelement location="worklight-ant-deployer.jar"/>
</classpath>
</taskdef>
<wladm url="http://localhost:10080/worklightadmin" user="admin" password="admin" secure="false">
<deploy-adapter runtime="myTime" file="//Users/admin/Documents/workspace/myTime/bin/Requests.adapter"/>
</wladm>
</target>
I am getting the following error in terminal:
: com.ibm.worklight.admin.restclient.RESTException: Error accessing http://localhost:10080/worklightadmin/management-apis/1.0/runtimes/myTime/adapters?locale=en_US: HTTP/1.1 404 Not Found
FWLSE3002E: The resource is not found.
FWLSE3041E: No MBean found for MobileFirst project 'myTime'. Possibly the MobileFirst runtime web application for MobileFirst project 'myTime' is not running. If it is running, use JConsole to inspect the available MBeans. If it is not running, full error details are available in the log files of the server.
at com.ibm.worklight.admin.restclient.RESTClient.getResponse(RESTClient.java:1247)
at com.ibm.worklight.admin.restclient.RESTClient.getResponseWithTimeout(RESTClient.java:1324)
at com.ibm.worklight.admin.restclient.RESTClient.getPOSTResponse(RESTClient.java:1442)
at com.ibm.worklight.admin.restclient.RESTClient.getPOSTFileResponse(RESTClient.java:1464)
at com.ibm.worklight.admin.commands.DeployAdapter.getResponse(DeployAdapter.java:41)
at com.ibm.worklight.admin.restclient.ActionClient.execute(ActionClient.java:84)
at com.ibm.worklight.admin.ant.types.AbstractActionElement.executeCommand(AbstractActionElement.java:76)
at com.ibm.worklight.admin.ant.types.ActionElement.executeCommands(ActionElement.java:43)
at com.ibm.worklight.admin.ant.WladmTask.executeCommands(WladmTask.java:705)
at com.ibm.worklight.admin.ant.WladmTask.execute(WladmTask.java:459)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
at org.apache.tools.ant.Main.runBuild(Main.java:851)
at org.apache.tools.ant.Main.startAnt(Main.java:235)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
In Eclipse the following error is shown:
ERROR ] FWLSE3002E: The resource is not found.
FWLSE3041E: No MBean found for MobileFirst project 'myTime'. Possibly the MobileFirst runtime web application for MobileFirst project 'myTime' is not running. If it is running, use JConsole to inspect the available MBeans. If it is not running, full error details are available in the log files of the server.
The same code is running fine for other projects.

It's clearly mentioned in the IBM Knowledgecenter you have to mention the <WorklightInstallDir>/WorklightServer/worklight-ant-deployer.jar
So you have to mention the WorklightServer install directory path (absolte path to the worklight-ant-deployer.jar File)
SO your taskdef should look like
<taskdef resource="com/worklight/ant/deployers/antlib.xml">
<classpath>
<pathelement location="C:\IBM\MobileFirst_Platform_Server\WorklightServer\worklight-ant-deployer.jar"/>
</classpath>
</taskdef>
The location is where your mobilefirst server is located. The jar file
alone wont do the trick. So try it out by giving the absolute path to the mobilefirst production server

Related

ANT error CreateProcess error=2

When I try to call simple JAR file via ANT. Whenever i execute I get the following error:
C:\temp\My\My_Ant.xml:20: Execute failed: java.io.IOException: Cannot run program "C:\PROGRA~1\Java\jre7\bin\java.exe -jar C:\temp\My\javatest.jar" (in directory "C:\temp\My"): CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1047)
at java.lang.Runtime.exec(Runtime.java:617)
at org.apache.tools.ant.taskdefs.launcher.Java13CommandLauncher.exec(Java13CommandLauncher.java:58)
at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:426)
at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:440)
at org.apache.tools.ant.taskdefs.ExecTask.runExecute(ExecTask.java:629)
at org.apache.tools.ant.taskdefs.ExecTask.runExec(ExecTask.java:670)
at org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:496)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
at org.apache.tools.ant.Main.runBuild(Main.java:854)
at org.apache.tools.ant.Main.startAnt(Main.java:236)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:285)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.(ProcessImpl.java:385)
at java.lang.ProcessImpl.start(ProcessImpl.java:136)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1028)
... 24 more
The Java program is simply printing "hello world!"
I call the ANT in the following way:
C:\Tools\ANT\apache-ant-1.9.7\bin\ant -buildfile My_Ant.xml
Any idea why I am getting this? when I run this via command line I get the correct message.
C:\temp\My>C:\PROGRA~1\Java\jre7\bin\java.exe -jar JavaTest.jar
hello from Java
Edit:
Ant Script:
<?xml version="1.0" encoding="UTF-8"?>
<project name="Issue Management" default="startActivity" xmlns:if="ant:if" xmlns:unless="ant:unless">
<property name="javaPath" value="C:\PROGRA~1\Java\jre7\bin\java.exe"/>
<property name="AnalyzerPath" value="C:\temp\my"/>
<property name="Analyzer" value="javatest.jar"/>
<!--Setting the location of ANT Contrib starts
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="C:/Tools/ANT/apache-ant-1.8.2/ant-contrib-1.0b3.jar" />
</classpath>
</taskdef>-->
<tstamp>
<format property="current.time" pattern="yyyyMMdd_HHmmss" />
</tstamp>
<target name="startActivity">
<echo>Issue Management script started at ${current.time}</echo>
<exec executable="${javaPath} -jar ${AnalyzerPath}\${Analyzer}" resultproperty="BuildErrorCode" failonerror="true" dir="${AnalyzerPath}">
<arg value="--help"/>
</exec>
<echo>Issue Management script ended at ${current.time}</echo>
</target>
</project>
The executable parameter needs to be set to the name or path of just the executable; command arguments should be specified separately using nested <arg> elements, for example:
<exec executable="${javaPath}" resultproperty="BuildErrorCode"
failonerror="true" dir="${AnalyzerPath}">
<arg value="-jar" />
<arg value="${AnalyzerPath}\${Analyzer}" />
<arg value="--help" />
</exec>
When you specified the whole command line as the executable, it was treated as a single command with embedded spaces, and so was not found:
Cannot run program "C:\PROGRA~1\Java\jre7\bin\java.exe -jar C:\temp\My\javatest.jar"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

MobileFirst Building a project WAR file with Ant

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"

IBM Worklight 6.1 - Ant build failed: Could not load definitions

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>

Deploy worklight application using Ant tasks

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.

Changed Sonar web.context, now ant task fails

I had a working sonar/jenkins installation, where sonar was installed on localhost:9000 and jenkins was on localhost:8080. I then wanted to hide those services behind Apache and protect them behind Crowd-authenticated account access.
So first, I relocated Jenkins to localhost:8080/jenkins and proxied it. Which worked.
Then I relocated Sonar to localhost:9000/sonar and proxied it. Which also worked.
But now, when I try to execute the Sonar task from within the build script in Jenkins, I get the following error:
sonar:
[sonar:sonar] Apache Ant version 1.7.1 compiled on April 26 2010
[sonar:sonar] Sonar Ant Task version: 1.2
[sonar:sonar] Loaded from: file:/usr/share/ant/lib/sonar-ant-task-1.2.jar
[sonar:sonar] Sonar work directory: /var/lib/jenkins/jobs/buzzcartes/workspace/.sonar
[sonar:sonar] Sonar server: http://localhost:9000
BUILD FAILED
org.sonar.batch.bootstrapper.BootstrapException: http://localhost:9000/api/server /version
at org.sonar.batch.bootstrapper.Bootstrapper.getServerVersion(Bootstrapper.java:71)
at org.sonar.ant.SonarTask.checkSonarVersion(SonarTask.java:225)
at org.sonar.ant.SonarTask.execute(SonarTask.java:188)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
at org.apache.tools.ant.Main.runBuild(Main.java:758)
at org.apache.tools.ant.Main.startAnt(Main.java:217)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
Caused by: java.io.FileNotFoundException: http://localhost:9000/api/server/version
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1610)
at java.net.URLConnection.getContent(URLConnection.java:748)
at org.sonar.batch.bootstrapper.Bootstrapper.remoteContent(Bootstrapper.java:123)
at org.sonar.batch.bootstrapper.Bootstrapper.getServerVersion(Bootstrapper.java:69)
... 18 more
I've updated the configuration in Jenkins to reflect the new location of http://localhost/sonar so I'm not sure where the http://localhost:9000/ is now coming from. I've looked in a variety of config files so far with no joy and Google isn't turning up any good answers so far. Any pointers would be most welcome.
Oh, my sonar task in build.xml looks like this:
<target name="sonar" depends="compile">
<!-- list of mandatory Sonar properties -->
<property name="sonar.sources" value="${basedir}/src" />
<!-- list of optional Sonar properties -->
<property name="sonar.projectName" value="buzzcartes" />
<property name="sonar.binaries" value="${basedir}/build" />
<property name="sonar.tests" value="${basedir}/test" />
<property name="sonar.libraries" value="${basedir}/lib" />
<sonar:sonar key="com.benjasoft:buzzcartes" version="0.1-SNAPSHOT" xmlns:sonar="antlib:org.sonar.ant" />
Thanks!
Try so set the sonar.host.url parameter
Maven
<sonar.host.url>http://wherever.sonar.com:9000</sonar.host.url>
Ant
<property name="sonar.host.url" value="http://wherever.sonar.com:9000" />
Strangely it is not documented here, but mentioned in the ant task guide.

Resources