I have several dynamic web projects in my workspace, each contains classes and refers to other utility projects (simple Java Projects), and to 3rd party jars.
These apps (dynamic web projects) are deployed on tomcat v6.0.6 using eclipse WTP (Helios 3.6)
When I update my workspace and new classes/resources/jars are extracted from the SVN repository, I re-publish my apps in tomcat apps, and restart it.
Occasionally, when tomcat starts one of my apps, it throws ClassNotFoundException, or complains about other missing resource. Sometimes I see that the a deployed resource (spring beans xml for example) is not up to date, and has 'old' content in it.
The common anti-voodoo-black-magic treatment I use: * stop / start tomcat * clean (when right click on the server configuration) * clean tomcat work directory * remove all apps from tomcat, clean, restart tomcat, add all apps
I need to run this 'procedure' several time until problem is solved.
Do you guys suffer from it as well ? Is this a known bug ? Any suggestions how to tackle it ? is using jars instead of utility projects will solve/reduce this problems?
I would consider using Embedded Jetty instead, I just want to avoid from proprietary scripts for running Jetty on a 'production' environment.
-- Yonatan
It happened to me a lot. I wouldn't call that Voodoo. I think that Eclipse WTP doesn't work well when you change stuff in the background (e.g. a maven build).
What I do to solve this is to avoid using it altogether. Instead I use Maven WAR plugin to deploy the application:
mvn war:inplace tomcat:inplace -DskipTests=true
This works very fast, as it doesn't need to assemble, and package the war.
Then to undeploy the application:
mvn tomcat:undeploy
I have scripts that
It looks something like this:
Start tomcat and deploy app:
#!/bin/sh
if [ -f $CATALINA_PID ]; then
echo "tomcat already running with pid " `cat $CATALINA_PID`
exit 1
fi
java -Dmy.arg=val -Dcatalina.home=<catalina-home> -Dlog4j.configuration=file:///log4j.xml -classpath <path-to-tomcat-lib>/bootstrap.jar:/usr/lib/jvm/java-6-sun-1.6.0.20/lib/tools.jar org.apache.catalina.startup.Bootstrap start &
echo $! > $CATALINA_PID
mvn war:inplace tomcat:inplace -DskipTests=true
Undeploy and Stop tomcat:
#!/bin/sh
mvn tomcat:undeploy
<path-to-tomcat>/shutdown.sh -force
rm $CATALINA_PID
The same with probably any other build script - its just a matter of how much code you will have to write.
I chose Maven's war:inplace goal is since it does very little, and thus runs very quickly. See here: maven.apache.org/plugins/maven-war-plugin/usage.html.
BTW, ANT and Gradle have a war task/plugin which can probably be configured to do something similar (I don't really remember...)
Hope this helps.
Another thing to look out for is that Project -> Build Automatically
should be enabled and the project should not have any build path problems.
Open the navigator view and confirm that the build folder is having generated class
files.
If the files are not being built they won't be published. Though this seems obvious it is easy to over look and wasted a lot of my time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With