Showing posts with label Tomcat. Show all posts
Showing posts with label Tomcat. Show all posts

Jan 14, 2015

Eclipse + Maven + Tomcat 7 : java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet




Sometimes when we setup a new web application project in Eclipse with Maven and using Tomcat 7 server, we might face following exception trace in server startup.



java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)
    at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:525)
    at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:507)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:126)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1099)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1043)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4957)
    at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5284)
    at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5279)
    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)



This exception usually occur due to missing "Maven Dependency" in Deployment Assembly.

Following the below steps will help resolving the issue:

- Open your eclipse-> right click on your maven project & choose "Properties"

- Click on "Deployment Assembly"

- Click "Add"

- Click on "Java Build Path Entries"

- Select "Maven Dependencies"

- Click Finish.

Rebuild and deploy it again.




Could not load the Tomcat server configuration at /Servers/Tomcat v7.0 Server at localhost-config. The configuration may be corrupt or incomplete



Problem usually arises when we use Eclipse Kepler and Tomcat 7.

Add Tomcat 7 to eclipse and when you start the tomcat or when you try to add a project to tomcat, you will get following error 


Could not load the Tomcat server configuration at /Servers/Tomcat v7.0 
Server at localhost-config. The configuration may be corrupt or incomplete


Follow the below steps to resolve the issue:


- Delete tomcat from eclipse-> servers tab.

- Copy all the contents inside your "TOMCAT_7_HOME/conf" directory.

- Paste the above copied content into "WORKSPACE_DIR/Servers/Tomcat v7.0 Server at localhost-config" directory.

- Open Eclipse and add the tomcat server to Servers tab.

- Add the project and start the server.