I have a simple web app using that uses servlets. I created it as a maven project and then imported it into eclipse ( file ->import -> existing maven projects)
The war gets deployed to tomcat 7 correctly.
However when I create a tomcat 7 server in Eclipse and then start tomcat in eclipse I get an exception when I run the application.
root cause
java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableMap
first.model.BeerExpert.<clinit>(BeerExpert.java:12)
first.servlet.BeerServlet.doPost(BeerServlet.java:26)
javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
java.lang.ClassNotFoundException: com.google.common.collect.ImmutableMap
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
first.model.BeerExpert.<clinit>(BeerExpert.java:12)
first.servlet.BeerServlet.doPost(BeerServlet.java:26)
javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
is there any specific class path setting that needs to be done in the eclipse/tomcat
Note: I am able to run mvn clean install and it creates the jar file. And then when I move the jar to a tomcat(7) webapp directory and restart it works just fine.
I am not posting details of the pom.xml because the application itself is working fine. However id it is needed in resolution I can post it.
Tomcat & Spring Web - Class Not Found Exception org.springframework.web.context.ContextLoaderListener
Right Click on your web project in Project Explorer -> select 'Properties'. Under project properties, select 'Deployment Assembly'.
The Deployment Assembly property page shows the content that will be published as a assembled artifact by Eclipse to the server. You need to tell Eclipse that you want all your Maven dependencies to be published too.
To do that, click 'Add' button, then select 'Java Build Path Entries'. Click Next and select Maven Dependencies. This will publish the Maven dependency JAR files to the lib folder when Eclipse publishes your project to WST server
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