I am running a jwsc ant task to generate a war file. It is working fine for me if I add the weblogic.jar to classpath before running the ant script (CLASSPATH=/opt/bea/weblogic91/server/lib/weblogic.jar export CLASSPATH)
But is is not working if I add this in my build.xml as follows:
<target name="GenerateWarFiles">
<path id="lib.jwsc.id">
<pathelement path="/opt/bea/weblogic91/server/lib/weblogic.jar"/>
</path>
<taskdef name="jwsc" classname="weblogic.wsee.tools.anttasks.JwscTask" classpathref="lib.jwsc.id"/>
<jwsc srcdir="${src.java.dir}" destdir="${build.war.file.dir}" verbose="on" debug="on" classpathref="lib.jwsc.id">
<jws file="sep/com/bt/prf/jws/TypeImpl.java" compiledWsdl="${ivy.lib.dir}/WSDLC/Jwslib-8.0.jar" />
</jwsc>
</target>
I am getting the following error.
[AntUtil.deleteDir] Deleting directory /var/tmp/_927vxb
BUILD FAILED
/wls_domains/CIT/cruisecontrol-bin-2.8.3/util/Ivy/build.xml:231: Deployment descriptor: /var/tmp/_927vxb/web.xml does not exist.
at weblogic.wsee.tools.anttasks.JwscTask.execute(JwscTask.java:184)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
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:1329)
at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
at org.apache.tools.ant.Main.runBuild(Main.java:698)
at org.apache.tools.ant.Main.startAnt(Main.java:199)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
Caused by: Deployment descriptor: /var/tmp/_927vxb/web.xml does not exist.
at org.apache.tools.ant.taskdefs.War.setWebxml(War.java:95)
at weblogic.wsee.tools.anttasks.JwscTask.jar(JwscTask.java:397)
at weblogic.wsee.tools.anttasks.JwscTask.pkg(JwscTask.java:331)
at weblogic.wsee.tools.anttasks.JwscTask.execute(JwscTask.java:166)
... 17 more
--- Nested Exception ---
Deployment descriptor: /var/tmp/_927vxb/web.xml does not exist.
at org.apache.tools.ant.taskdefs.War.setWebxml(War.java:95)
at weblogic.wsee.tools.anttasks.JwscTask.jar(JwscTask.java:397)
at weblogic.wsee.tools.anttasks.JwscTask.pkg(JwscTask.java:331)
at weblogic.wsee.tools.anttasks.JwscTask.execute(JwscTask.java:166)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
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:1329)
at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
at org.apache.tools.ant.Main.runBuild(Main.java:698)
at org.apache.tools.ant.Main.startAnt(Main.java:199)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
Total time: 1 minute 3 seconds
I am running weblogic91 in Solaris.
I'm betting that in your deployment target (Which isn't posted here) is trying to 'clean' up the deployment directory, and is failing when it can't find the file called /var/tmp/_927vxb/web.xml
3 suggestions:
Run touch /var/tmp/_927vxb/web.xml from the command line and try to run the build/deployment again. This will create an empty file that will at least let you get past the file not found on delete error. This is not a long term solution, but rather an attempt to expose the real issue.
Look at line 231 in your /wls_domains/CIT/cruisecontrol-bin-2.8.3/util/Ivy/build.xml file. Perhaps there is a delete ant task that is failing on error. If this is the case, add `failonerror="false" to the ant task that is causing the issue.
Post more of your build file here. Being able to align the line numbers in the file with the error will help in decoding the issue.
Related
So I made an ANT target to deploy our app to Tomcat on a remote development server. The ANT deploy to tomcat target works 100% perfect on a local Tomcat instance. When I deploy to the remote server I get a fat 500 error but the application actually deploys to the server and we can view and use it just fine as if there were no errors.
Super cool that it works but the 500 error causes the ANT target to say the build failed. If ANT says the build failed, so will Hudson our build server, which means we will have sad red dots instead of happy green ones.
We are using the latest and greatest ANT with Tomcat v9.
Below is the error I get when I execute my "ant deploy-dev" target.
[username#localhost app.directory]$ ant deploy-dev
Buildfile: /home/username/git/app.directory/build.xml
Trying to override old definition of datatype resources
deploy-dev:
[echo] Deploying app to: https://dev.myapp.com
BUILD FAILED
/home/username/git/app.directory/build.xml:73: The following error occurred while executing this line:
/home/username/git/app.directory/build.xml:146: java.io.IOException: Server returned HTTP response code: 500 for URL: https://dev.myapp.com/manager/text/deploy?path=%2Fmy-app%2F
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1840)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
at org.apache.catalina.ant.AbstractCatalinaTask.execute(AbstractCatalinaTask.java:254)
at org.apache.catalina.ant.DeployTask.execute(DeployTask.java:194)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
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.taskdefs.Sequential.execute(Sequential.java:68)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
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.taskdefs.MacroInstance.execute(MacroInstance.java:396)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
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)
Total time: 3 minutes 3 seconds
To get an idea of what is running, here is the important parts of the ANT build.xml.
<property environment="env"/>
<property file="build.properties"/>
<!-- Import -->
<import file="${env.CATALINA_HOME}/bin/catalina-tasks.xml" optional="true"/>
<!-- The deploy to Tomcat target -->
<target name="deploy-local" description="Deploy the app to local Tomcat">
<tomcat-deploy base-url="${url.base.local}"/>
</target>
<target name="deploy-dev" description="Deploy the app to dev Tomcat">
<tomcat-deploy base-url="${url.base.dev}"/>
</target>
<target name="undeploy-local" depends="stop-local" description="Undeploy the app from local Tomcat">
<tomcat-undeploy base-url="${url.base.local}"/>
</target>
<target name="undeploy-dev" depends="stop-dev" description="Undeploy the app from dev Tomcat">
<tomcat-undeploy base-url="${url.base.dev}"/>
</target>
<target name="stop-local" description="Stop the app on local Tomcat">
<tomcat-stop base-url="${url.base.local}"/>
</target>
<target name="stop-dev" description="Stop the app on dev Tomcat">
<tomcat-stop base-url="${url.base.dev}"/>
</target>
<macrodef name="tomcat-deploy">
<attribute name="base-url"/>
<sequential>
<echo>Deploying app to: #{base-url}</echo>
<deploy url="#{base-url}/manager/text" username="${username}" password="${password}"
path="/${app.name}" war="file:${war.path}.war"/>
</sequential>
</macrodef>
<macrodef name="tomcat-undeploy">
<attribute name="base-url"/>
<sequential>
<echo>Un-deploying app from: #{base-url}</echo>
<undeploy
failonerror="no"
url="#{base-url}/manager/text"
username="${username}"
password="${password}"
path="/${app.name}"
/>
</sequential>
</macrodef>
<macrodef name="tomcat-stop">
<attribute name="base-url"/>
<sequential>
<echo>Stopping the app at: #{base-url}</echo>
<stop url="#{base-url}/manager/text" username="${username}"
password="${password}" path="/${app.name}" />
</sequential>
</macrodef>
Anyone have any idea why the deploy to remote works but still returns an error? The error I get is kind of vague so I don't know what I could do to debug it.
The problem was the server was taking too long to deploy the app. Somewhere the Tomcat Deploy target is waiting for a response from the server saying the app was deployed. Unfortunately the only error is the 500 and there is nothing else to go on.
The solution, I simply re-installed Tomcat with Version 9, up from 8, and everything turned on much faster and the build was successful.
I can't really say this is the best answer but I got everything working.Hopefully someone has a better solution one day.
I have a jar with an ant task in it. My com/mebigfatguy/stringliterals/antlib.xml is
<antlib xmlns:stringliterals="ant:com.mebigfatguy.stringliterals">
<taskdef name="stringliterals" classname="com.mebigfatguy.stringliterals.StringLiteralsTask"/>
</antlib>
running jar tf stringliterals.jar i get
META-INF/
META-INF/MANIFEST.MF
com/
com/mebigfatguy/
com/mebigfatguy/stringliterals/
com/mebigfatguy/stringliterals/antlib.xml
com/mebigfatguy/stringliterals/SLClassVisitor.class
com/mebigfatguy/stringliterals/StringLiteralsTask.class
com/mebigfatguy/stringliterals/SLMethodVisitor.class
com/mebigfatguy/stringliterals/Literal.class
META-INF/maven/
META-INF/maven/com.mebigfatguy.stringliterals/
META-INF/maven/com.mebigfatguy.stringliterals/stringliterals/
META-INF/maven/com.mebigfatguy.stringliterals/stringliterals/pom.xml
META-INF/maven/com.mebigfatguy.stringliterals/stringliterals/pom.properties
com/mebigfatguy/org/
com/mebigfatguy/org/objectweb/
com/mebigfatguy/org/objectweb/asm/
com/mebigfatguy/org/objectweb/asm/AnnotationVisitor.class
com/mebigfatguy/org/objectweb/asm/AnnotationWriter.class
com/mebigfatguy/org/objectweb/asm/Attribute.class
com/mebigfatguy/org/objectweb/asm/ByteVector.class
com/mebigfatguy/org/objectweb/asm/ClassReader.class
com/mebigfatguy/org/objectweb/asm/ClassVisitor.class
com/mebigfatguy/org/objectweb/asm/ClassWriter.class
com/mebigfatguy/org/objectweb/asm/Context.class
com/mebigfatguy/org/objectweb/asm/Edge.class
com/mebigfatguy/org/objectweb/asm/FieldVisitor.class
com/mebigfatguy/org/objectweb/asm/FieldWriter.class
com/mebigfatguy/org/objectweb/asm/Frame.class
com/mebigfatguy/org/objectweb/asm/Handle.class
com/mebigfatguy/org/objectweb/asm/Handler.class
com/mebigfatguy/org/objectweb/asm/Item.class
com/mebigfatguy/org/objectweb/asm/Label.class
com/mebigfatguy/org/objectweb/asm/MethodVisitor.class
com/mebigfatguy/org/objectweb/asm/MethodWriter.class
com/mebigfatguy/org/objectweb/asm/Opcodes.class
com/mebigfatguy/org/objectweb/asm/Type.class
com/mebigfatguy/org/objectweb/asm/TypePath.class
com/mebigfatguy/org/objectweb/asm/TypeReference.class
com/mebigfatguy/org/objectweb/asm/signature/
com/mebigfatguy/org/objectweb/asm/signature/SignatureReader.class
com/mebigfatguy/org/objectweb/asm/signature/SignatureVisitor.class
com/mebigfatguy/org/objectweb/asm/signature/SignatureWriter.class
as you can see the task class is there
I put the jar in ~/.ant/lib, and When i try to run a task that references it like this:
<target name="literals" xmlns:stringliterals="antlib:com.mebigfatguy.stringliterals" description="generate report of string literals used in code">
<stringliterals:stringliterals>
<classpath refid="fb-contrib.classpath"/>
</stringliterals:stringliterals>
</target>
I get
literals:
parsing buildfile jar:file:/home/dave/.ant/lib/stringliterals-0.2.0.jar!/com/mebigfatguy/stringliterals/antlib.xml with URI = jar:file:/home/dave/.ant/lib/stringliterals-0.2.0.jar!/com/mebigfatguy/stringliterals/antlib.xml from a zip file
Finding class com.mebigfatguy.stringliterals.StringLiteralsTask
BUILD FAILED
/home/dave/dev/fb-contrib/build.xml:245: The following error occurred while executing this line:
jar:file:/home/dave/.ant/lib/stringliterals-0.2.0.jar!/com/mebigfatguy/stringliterals/antlib.xml:2: taskdef class com.mebigfatguy.stringliterals.StringLiteralsTask cannot be found
using the classloader AntClassLoader[]
at org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:607)
at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:237)
at org.apache.tools.ant.taskdefs.Antlib.execute(Antlib.java:177)
at org.apache.tools.ant.taskdefs.Definer.loadAntlib(Definer.java:428)
at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:277)
at org.apache.tools.ant.ComponentHelper.checkNamespace(ComponentHelper.java:874)
at org.apache.tools.ant.ComponentHelper.getDefinition(ComponentHelper.java:307)
at org.apache.tools.ant.ComponentHelper.createComponent(ComponentHelper.java:284)
at org.apache.tools.ant.ComponentHelper.createComponent(ComponentHelper.java:263)
at org.apache.tools.ant.UnknownElement.makeObject(UnknownElement.java:429)
at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:163)
at org.apache.tools.ant.Task.perform(Task.java:347)
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)
Caused by: java.lang.ClassNotFoundException: com.mebigfatguy.stringliterals.StringLiteralsTask
at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1366)
at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1315)
at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1068)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:579)
... 21 more
I've done this several times before with no issues, this time however i don't see where i've gone wrong. Any way to debug this classloader issue?
GitHub project here https://github.com/mebigfatguy/stringliterals
The problem turned out to be a badly formatted manifest file. sorry!
I'm using Ant 1.9.3 and Tomcat version 8.0. I'm using the Ant deploy target to deploy web apps in the Apache Tomcat using the manager credentials. The deploy target fails with the following exception:
java.lang.NoClassDefFoundError:
org/apache/tomcat/util/codec/binary/Base64
at org.apache.catalina.ant.AbstractCatalinaTask.execute(AbstractCatalina
Task.java:204)
at org.apache.catalina.ant.DeployTask.execute(DeployTask.java:196)
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(DelegatingMethodAcces
sorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
a: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(DefaultExe
cutor.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)
Caused by: java.lang.ClassNotFoundException: org.apache.tomcat.util.codec.binary
.Base64
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 19 more
When I tried to find the class Base64 in the package org\apache\tomcat\util\codec\binary\ which is in tomcat-util.jar, and it is in the classpath which I've verified by an echo in Ant build file.
I'm not able to solve the issue.
Just in case someone runs into the same problem I was having:
I was following the tutorial on the Tomcat website and I ran into the same NoClassDefFoundError issue when I tried to run ant install.
The tutorial mentions that you have to copy $CATALINA_HOME/lib/catalina-ant.jar1 (which contains the implementation code for the Ant custom tasks) to the lib directory of your Ant installation.
It does not mention, however, that you need to do the same thing for tomcat-util.jar. As soon as I copied tomcat-util.jar to my Ant directory, things started working (source).
1$CATALINA_HOME is the directory of your Tomcat installation, e.g. /usr/share/tomcat8
Please make sure you have added the tomcat-util.jar in the classpath as below.
<path id="catalina-ant-classpath">
<!-- We need the Catalina jars for Tomcat -->
<!-- * for other app servers - check the docs -->
<fileset dir="${appserver.lib}">
<include name="catalina-ant.jar"/>
<include name="tomcat-util.jar"/>
</fileset>
</path>
This is the build file:
<exec executable="python" failonerror="true">
<arg line="${installer.izpack.dir}/utils/wrappers/izpack2exe/izpack2exe.py"/>
<arg line="--file=${basedir}/installer/EasyIT-installer.jar"/>
<arg line="--output=${basedir}/installer/EasyIT-installer.exe"/>
<arg line="--no-upx"/>
</exec>
And the output:
BUILD FAILED
E:\Java Projects\Spark Projects\EastIT - Copy\build\build.xml:873: Execute failed: java.io.IOException: Cannot run program "python" (in directory "E:\Java Projects\Spark Projects\EastIT - Copy"): CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
at java.lang.Runtime.exec(Runtime.java:615)
at org.apache.tools.ant.taskdefs.Execute$Java13CommandLauncher.exec(Execute.java:8 62)
at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:481)
at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:495)
at org.apache.tools.ant.taskdefs.ExecTask.runExecute(ExecTask.java:631)
at org.apache.tools.ant.taskdefs.ExecTask.runExec(ExecTask.java:672)
at org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:498)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor15.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.ja va: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:392)
at org.apache.tools.ant.Target.performTasks(Target.java:413)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java :41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.apache.tools.ant.Main.runBuild(Main.java:811)
at org.apache.tools.ant.Main.startAnt(Main.java:217)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
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.<init>(ProcessImpl.java:189)
at java.lang.ProcessImpl.start(ProcessImpl.java:133)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1021)
... 23 more
Total time: 50 seconds
Make sure that python is in the PATH where you're running the build, or specify an absolute path to your python executable in the exec task.
Review the docs for the exec task for any specific instructions on using windows vs. not-windows. Note that your specific error is mentioned there:
A common problem is not having the executable on the PATH. In case you get an error message Cannot run program "...":CreateProcess error=2. The system cannot find the path specified. have a look at your PATH variable. Just type the command directly on the command line and if Windows finds it, Ant should do it too. (Otherwise ask on the user mailinglist for help.) If Windows can not execute the program add the directory of the programm to the PATH (set PATH=%PATH%;dirOfProgram) or specify the absolute path in the executable attribute in your buildfile.
I am trying to run a Java class as part of the deployment of my project (I want to create some resources at deployment, which can then be read at runtime).
For the most part, I am using maven for the build cycle - in particular for dependency management.
This what I've got to; creating a path (run), and adding the dependencies from maven using the maven ant tasks, and then running a target that calls a java class (MyClass), which has been compiled to ...MyClass.class in the target\src directory, using a classpath of that directory and the run path specified above.
<path id="run" />
<artifact:dependencies pathid="run">
<artifact:pom file="pom.xml" id="my_project" />
</artifact:dependencies>
<target name="runMyClass">
<java classname="...MyClass" fork="yes" maxmemory="512M" append="true">
<classpath>
<pathelement location="target\classes"/>
<pathelement id="run" />
</classpath>
</java>
</target>
I know that the target\classes is correct - if I comment out the addition of the run path, it finds the class, but reports that some of the imports in the class are not available on the classpath.
However, when I run this, I get the following stack trace:
C:\somepath\my_project\build.xml:118: java.lang.NullPointerException
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:116)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:390)
at org.apache.tools.ant.Target.performTasks(Target.java:411)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.apache.tools.ant.Main.runBuild(Main.java:809)
at org.apache.tools.ant.Main.startAnt(Main.java:217)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.ant.execution.AntMain2.main(AntMain2.java:32)
Caused by: java.lang.NullPointerException
at org.apache.tools.ant.types.resources.FileResourceIterator.addFiles(FileResourceIterator.java:104)
at org.apache.tools.ant.types.resources.FileResourceIterator.<init>(FileResourceIterator.java:95)
at org.apache.tools.ant.types.Path$PathElement.iterator(Path.java:124)
at org.apache.tools.ant.types.resources.Union.getCollection(Union.java:123)
at org.apache.tools.ant.types.resources.Union.getCollection(Union.java:107)
at org.apache.tools.ant.types.resources.BaseResourceCollectionContainer.cacheCollection(BaseResourceCollectionContainer.java:265)
at org.apache.tools.ant.types.resources.BaseResourceCollectionContainer.iterator(BaseResourceCollectionContainer.java:142)
at org.apache.tools.ant.types.Path.iterator(Path.java:710)
at org.apache.tools.ant.types.resources.Union.getCollection(Union.java:123)
at org.apache.tools.ant.types.resources.Union.list(Union.java:86)
at org.apache.tools.ant.types.Path.list(Path.java:378)
at org.apache.tools.ant.types.Path.addExisting(Path.java:331)
at org.apache.tools.ant.types.Path.addExisting(Path.java:319)
at org.apache.tools.ant.types.Path.concatSpecialPath(Path.java:572)
at org.apache.tools.ant.types.Path.concatSystemClasspath(Path.java:532)
at org.apache.tools.ant.types.CommandlineJava.haveClasspath(CommandlineJava.java:647)
at org.apache.tools.ant.types.CommandlineJava.addCommandsToList(CommandlineJava.java:437)
at org.apache.tools.ant.types.CommandlineJava.getCommandline(CommandlineJava.java:405)
at org.apache.tools.ant.types.CommandlineJava.describeCommand(CommandlineJava.java:482)
at org.apache.tools.ant.taskdefs.Java.checkConfiguration(Java.java:176)
at org.apache.tools.ant.taskdefs.Java.execute(Java.java:107)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
... 16 more
To me, this looks like an exception is being thrown in the ant code in the process of adding the path set to the classpath, but I could be wrong.
Can anyone suggest (any of the following):
how I might go about debugging this?
an alternative approach to do what I'm trying to do (described
above)?
A little further playing gave me a workable solution...
Rather than refering to the maven dependencies as a path, I can refer to them using a fileset:
<fileset id="run" />
<artifact:dependencies filesetid="run">
<artifact:pom file="pom.xml" id="my_project" />
</artifact:dependencies>
<target name="runMyClass">
<java classname="...MyClass" fork="yes" maxmemory="512M" append="true">
<classpath>
<pathelement location="target\classes"/>
<fileset refid="run" />
</classpath>
</java>
</target>
I don't know what was going on with the other approach, whether it's user error or a bug, so if anyone has any suggestions, I would appreciate comments.