I get the following exception when I try to start Tomcat through Eclipse (via right click on Project, Run As -> Run on Server).
SEVERE: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521) at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:415) at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:397) at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4660) at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226) at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) Jun 12, 2011 8:46:11 PM org.apache.catalina.core.StandardContext listenerStart
I am building my project using Maven (m2eclipse). I have added the necessary dependencies to Spring libraries, and I can see the spring-web.jar file in the lib directory of the final artifact (which contains the class). When I deploy the application outside of IDE, it works fine.
Any pointers as to why this happens would be highly appreciated.
Apache Tomcat is a popular open source web server and Servlet container for Java code. As the reference implementation of Java Servlet and Java Server Pages (JSP), Tomcat was started at Sun Microsystems, which later donated the code base to the Apache Software Foundation.
Key difference between Tomcat and the Apache HTTP Server the Apache HTTP Server, but the fundamental difference is that Tomcat provides dynamic content by employing Java-based logic, while the Apache web server's primary purpose is to simply serve up static content such as HTML, images, audio and text.
What is Tomcat? - [Instructor] Tomcat is a lightweight and robust application server for Java. It's free and open source, written in Java, and designed for hosting Java applications. Tomcat has been around for a long time, over 20 years.
Apache Tomcat (Link resides outside IBM) is an open source application server that executes Java Servlets, renders and delivers web pages that include JavaServer Page code, and serves Java Enterprise Edition (Java EE) applications. Released in 1998, Tomcat is the most widely used open source Java application server.
I faced the same problem few days ago with m2eclipse (without WTP integration add on available via m2eclipse-extras) on Eclipse Indigo. I created a Maven Web Module and manually added the Dynamic Web Module facet to it. When I deployed it on Eclipse WST Tomcat Server, it appeared that my Maven dependencies are not getting pushed to the server when the project is published to it.
The solution was simple. 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.
This approach worked for me.
The easiest way to tell what Eclipse will put in your war file for server deployments is to do a right click -> Export -> WAR file. You can then uncompress this and see what's inside.
If you open up ".settings/org.eclipse.wst.common.component" you should see the definition of the web tools webapp, and see something like:
<project-modules id="moduleCoreId" project-version="1.5.0"> <wb-module deploy-name="MyApp"> <wb-resource deploy-path="/" source-path="/src/main/webapp"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/> <property name="java-output-path" value="target/classes"/> <property name="context-root" value="MyApp"/> </wb-module> </project-modules>
On your build path in Eclipse, make sure "Maven Dependencies" appears in Libraries. The last versions of the m2eclipse plugin and WST should automatically pick up the Maven dependencies and drop them in WEB-INF/lib inside your war file.
Last but not least, you may want to consider picking up the latest copy of SpringSource Tool Suite (STS). STS has a number of good features, including bundling the latest m2eclipse and WST. You can still use it with Tomcat (or their version of Tomcat), and it has some archetypes and tutorials in there to get a webapp working quickly.
Enjoy!
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