0

I created a Spring MVC web application following this tutorial: http://www.journaldev.com/2433/spring-mvc-tutorial-for-beginners-with-spring-tool-suite

I am able to access it using the built-in server in the STS. Now, I want to deploy and test my web application using tomcat devloader plugin in eclipse. When I try to run it using tomcat I get this error:

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:1680)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4153)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4709)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:583)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:675)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:601)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:822)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

Do you have any idea what may have cause this error and how to possibly solve this?

Thanks.

jaypax123
  • 188
  • 2
  • 14
  • You have forgot to add some library to the bin. – Zeus Jul 03 '14 at 16:37
  • What libraries should I be adding? – jaypax123 Jul 03 '14 at 16:42
  • as per google spring-web.jar – Zeus Jul 03 '14 at 16:43
  • I added that library now along with 3 other spring libraries namely, spring-beans,spring-context and spring-core. Now I get a different error: SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory – jaypax123 Jul 03 '14 at 16:45

2 Answers2

0

The spring-web.jar from here and add it to the classpath. Also just make sure your server classpath has included the Spring jar library.Also include commons loggings.jar

SparkOn
  • 8,806
  • 4
  • 29
  • 34
0

As you keep getting these NoClassDefFoundError /CLassNotFound exceptions try to copy the first line which is 'org/apache/commons/logging/LogFactory' and google it appending .jar at the very end. You will not know what jar to include.

Zeus
  • 6,386
  • 6
  • 54
  • 89
  • I have added all the jars needed and there are no errors in running tomcat BUT I can't access my page. I always get HTTP Status 404. – jaypax123 Jul 03 '14 at 17:09
  • check the url that you are trying. what is the project name? what is the .jsp/.html that you are trying and what the url? – Zeus Jul 03 '14 at 17:12
  • In my tomcat settings, the context name is sme. I also added the directory as web root: /src/main/webapp. In the devloader settings, I checked all checkboxes. Then when I try to access localhost:8080/sme/ in the browser, I get Http 404 error. Then there is no stacktrace. – jaypax123 Jul 03 '14 at 17:15
  • Do you have a starting page setup for your project ? drop a index.html in the root of your project in the tomcat and try localhost:8080/sme/index.html – Zeus Jul 03 '14 at 17:18
  • Try http://stackoverflow.com/questions/14648167/how-to-configure-welcome-file-list-in-web-xml this welcomepage in web.xml if you dont want to mention the index.html. I think your project is setup properly. – Zeus Jul 03 '14 at 17:20
  • When I am not using tomcat devloader, I can view my webapp in the browser without any errors. It is most likely that my project was not loaded properly in the devloader. – jaypax123 Jul 03 '14 at 17:34
  • You should add the project to the devloader by right clicking on the tomcat server > add project – Zeus Jul 03 '14 at 17:41