My goal is to start tomcat using Ant. Here is my script:
<target name="tomcat-start">
<java jar="${tomcat.home}/bin/bootstrap.jar" fork="true" dir="${tomcat.home}">
<classpath>
<fileset dir="${tomcat.home}/bin">
<include name="bootstrap.jar"/>
<include name="tomcat-juli.jar"/>
</fileset>
</classpath>
<jvmarg value="-Dcatalina.home=${tomcat.home}"/>
</java>
</target>
After script execution I receive this output:
java.lang.NoClassDefFoundError: org/apache/juli/logging/LogFactory
at org.apache.catalina.startup.Bootstrap.<clinit>(Bootstrap.java:60)
Caused by: java.lang.ClassNotFoundException: org.apache.juli.logging.LogFactory
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:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 1 more
Exception in thread "main"
Java Result: 1
I've checked: org.apache.juli.logging.LogFactory
class is presented in tomcat-juli.jar
!
What could be wrong?
If you want to stick with using catalina, the proper method is to add \setenv.bat with contents like:
I discovered that by reading catalina.bat. Someone might want to update this with the proper Tomcat doc
For some unknown weird reasons tomcat doesn't start in my system even when I launch it from command line using
java -jar
command.However, I managed to start it using
java -cp "bin\bootstrap.jar;bin\tomcat-juli.jar" org.apache.catalina.startup.Bootstrap
command, executed fromtomcat.home
directory.The code in ant which does the same:
Check out the
startup.sh
batch file or shell script of tomcat. It has bunch of other files apart frombootstrap.jar
. checksetclasspath.sh
. It has all jars are being set in class path.Other more clean approach would be to invoke
startup.sh
script from ant. This will do everything for what it takes to start Tomcat Server.