I am using eclipse
to develop and test a spring mvc
application. I use Run as...Run on server
frequently during development to test minor changes. I am running into a ClassNotFound
error whose solution seems to involve moving a couple of jars into the tomcat 8
lib
directory so that they can be available at run time. (The classes containing the jars are in the application build path in eclipse.) The problem with moving the jars to the tomcat lib
folder is that the jars are also needed at compile time. When I move the jar
to $CATALINA_HOME/lib
, I get an error indicating that there are duplicate jars due to the jar
being in my pom.xml
. But if I delete it from my pom.xml
, eclipse
will not compile the app. How can I move a jar to $CATALINA_HOME/lib and still have eclipse compile my app?
I tried setting <scope>runtime</scope>
and <scope>provided</scope>
but neither of these addresses the problem. Here is what I have in my pom.xml
:
<dependency>
<groupId>javax.mail</groupId>
<artifactId>javax.mail-api</artifactId>
<version>1.5.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
</dependency>
EDIT#1:
I also tried moving the jar
to the tomcat lib
folder and then adding the jar
to the buildpath
in eclipse
as an external jar
so that I could delete the dependencies from pom.xml
and still have eclipse
compile the app. But when I do this, eclipse
gives me the following error each time I try Run As..Run on Server
:
Several ports (8080, 8009) required by Tomcat v8.0 Server at localhost are
already in use. The server may already be running in another process, or a
system process may be using the port. To start this server you will need to
stop the other process or change the port number(s).
Of course, I went to the tomcat bin
folder and ran shutdown.sh
, but that did not stop the new error.
EDIT#2
When I shut down tomcat
from within eclipse
by clicking on the red button, eclipse
says that tomcat has been stopped. However, when I try to restart tomcat
by doing Run As..Run on Server
again, I get the error described in EDIT#1
above. The temporary resolution of this error comes when I completely shut down my computer and reboot. Then I am able to do Run As..Run on Server
again and recreate the situation. Only now a new error is being thrown. I documented the new error in a separate posting. However, I keep getting the same problem of the error message from EDIT#1
every time I try to do successive Run As..Run on Server
launches to test small changes in the code. So this current question is not resolved because putting the java mail jar
in tomcat lib
folder and using scope provided requires an unacceptable reboot every time I want to relaunch the app from within eclipse
. shutdown.sh
does not work either.