Posts

Showing posts from March, 2009

java.lang.ClassNotFoundException: org.apache.tools.ant.Main

This error should not be occuring when you install Ant out-of-the-box and run it. However, on the rare occasions it does occur - the solution is quite simple. java.lang.ClassNotFoundException: org.apache.tools.ant.Main at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:244) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67) Take a look at the ANT_HOME/lib folder - and ensure that the ant.jar is in there and showing a size of 1MB or higher. It is usually due to a corrupted version of ant.jar in the above path.

Executing multiple mvn commands from a Windows bat file

When running Maven, if you try to run multiple Maven commands in a batch (.bat) file, it only runs the first one and exits to the command prompt mvn clean mvn package This occurs since mvn itself is a bat file. To overcome this, you need to stop Windows passing control to the mvn.bat script by using the call command for each call to mvn. call mvn clean call mvn package Additionally, to catch failures you will need to do this call mvn clean echo Exit Code = %ERRORLEVEL% if not "%ERRORLEVEL%" == "0" exit /b call mvn package echo Exit Code = %ERRORLEVEL% if not "%ERRORLEVEL%" == "0" exit /b A failure throws an ERRORLEVEL higher than 0. Otherwise it will keep moving ahead even if it fails. Note: if you're using maven 2.0.7 or older, there is a possibility that the mvn does not return an ERRORLEVEL > 0 for the process to exit. Lots of examples are available here http://www.google.co.uk/search?hl=en&q=mvn+exit+...