Resolving ant errors can be a pain sometimes because of the vague error messages you get on the console. Yesterday I was getting a "Process fork failed." error on my Junit task and all I got on the console was
BUILD FAILED
C:\work\builds\build.xml:58: Process fork failed.
I wasted a couple of hours on google looking for an answer and after failing to fix the issue with several suggested solutions, I stumbled upon one post that suggested enabling the verbose output of Ant. All you had to do was pass -verbose as a command line parameter to ant
ant -verbose <target>
That made ant display lot of details including the actual exception. In my case it was:
C:\work\build\build.xml:58: Process fork failed.
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeAsForked(JUnitTask.java:871)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:679)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeOrQueue(JUnitTask.java:1413)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:633)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at org.apache.tools.ant.Main.runBuild(Main.java:668)
at org.apache.tools.ant.Main.startAnt(Main.java:187)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
Caused by: java.io.IOException: CreateProcess: C:\bea92\jdk150_04\jre\bin\java.exe ...
I found the issue a little bit above the exception on the console and it was the massive classpath value passed into the java.exe. Obviously the Windows command line has a limitation on the length of command line arguments and the value for classpath was exceeding it.
When I checked the build file I found the error, where it was adding the files in a directory instead of the directory into the classpath. Fixed that small error and all was fine again.
Anyway glad I got to know about the verbose switch in Ant and hopefully I wouldn't have to waste a lot of time again fixing ant issues again.
5 comments:
Can you please let me know, how did you go around fixing this err?
Did you create a jar?
In my case it was adding all the xml and porperties files in a directory to the classpath. This was unnecessary as just adding the path to the directory was enough.
If you are having the same issue you might be doing something wrong as even with the command line limitation you can pass a very long string.
Check the classpath value and remove if there are any unwanted paths and if you have very long /deep absolute directory paths (e.g folder where your jar files are), try to move / rename to make them shorter.
Brilliant - thanks for this! I had the 'process fork failed' error and yours was the first thing to come up on google and fixed it instantly!
Thanks for grate post. It is short precise and clear. It even attracted me to read more of your other post. I would like to subscribe to your Blog as a reader and get an e-mail for each new one. Is it possible to do that?
Best regards and wish the best
thas
yes this helped me as well. I got the same error and after reducing the length of the class paths i worked for me.
Post a Comment