10

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

skaffman
  • 398,947
  • 96
  • 818
  • 769
Yonatan Maman
  • 2,428
  • 1
  • 24
  • 34
  • This happens to me too. Same voodoo applies. My only solution is unfortunatly not to use eclipse/wtp – Ran Dec 02 '10 at 19:34
  • One thing I noticed when this issue happened to me was when I ignored the build folder from the eclipse project (using the Properties -> Resource -> Resource Filters), added the folder back in everything is fine.. – Chandu Sep 27 '16 at 13:22

7 Answers7

3

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

  • deploy and start tomact
  • undeploy and stop tomcat

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.

Eran Harel
  • 2,325
  • 19
  • 28
  • eran- does it mean that I need to use maven to manage all my dependencies? or I can I use it for war deployment only? – Yonatan Maman Dec 04 '10 at 06:33
  • Yonatan, maven is not a must here. Since I use maven anyway, it was the simplest solution for me. You can do the same with 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: http://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...). – Eran Harel Dec 04 '10 at 06:51
  • Yonatan, is there anything missing in my reply? – Eran Harel Dec 07 '10 at 07:44
  • I'm not using maven at all and I have the same problem. Even when the resources have changed IN eclipse. – mjaggard May 02 '13 at 10:45
2

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.

Kshitiz Sharma
  • 17,947
  • 26
  • 98
  • 169
1

I had a similar problem. When I published a web application, Eclipse was not including one of the jar and hence publish to sever through Eclipse fails. I corrected this by modifying the .classpath file of the project to correct dependency as below. To makes sure that its in sync with other jars configuration.

<classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.17/log4j-1.2.17.jar" sourcepath="M2_REPO/log4j/log4j/1.2.17/log4j-1.2.17-sources.jar">
            <attributes>
            <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
        </attributes>
        </classpathentry>
Satya
  • 11
  • 1
1

Interesting behaviour.... Something similar was happening on my Linux machine due to permission issues.

Anyway, i suggest not to use WTP. Try ant build script instead. Its simple and for me it works brilliant.

JohnGray
  • 656
  • 1
  • 10
  • 27
1

Been working with Eclipse since it came out, these problems have always existed. Arrived here because atm my web.xml doesn't get deployed anymore. Especially in combination with m2eclipse you'll never know what happens when you try to start your Tomcat. Everybody I know how has worked with Eclipse has these problems, I don't understand why they don't get fixed...and unfortunately working as a contractor means I can't choose my IDE or the container or the way publishing is done, so most of the time I'm stuck with WTP.

Nicolas Mommaerts
  • 3,207
  • 4
  • 35
  • 55
0

one possible solution could be that your bin folder is not getting created. check that you have not deleted build/bin folder and it does exists in your work space.

Ali
  • 1,480
  • 2
  • 20
  • 30
0

It seems progress is being made on solving this problem.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=365748

Hopefully it will be fixed for the next release of Eclipse.

Jules
  • 14,841
  • 9
  • 83
  • 130