0
votes

I'm trying to run the most up to date spring sample projects in eclipse but i'm always getting ClassNotFoundException. (For example with spring-mvc-showcase project)

Environment:

  • Ubuntu 12.04, 64bit (same problem with 13.10)
  • openjdk-7-jdk, openjdk-7-jre installed
  • Eclipse kepler Java EE version, STS installed.

Steps:

  • I make a new project: Spring/Import Spring Getting Started Content
  • When all the dependencies loaded, right click on the project name / Run As / Run On Server: J2EE Preview at localhost

Jetty output:

2014-01-16 20:13:01.241:INFO:oejs.Server:jetty-8.1.10.v20130312 2014-01-16 20:13:02.905:WARN:oejw.StandardDescriptorProcessor:Could not instantiate listener org.springframework.web.context.ContextLoaderListener java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:424) at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:377) at org.eclipse.jetty.server.handler.ContextHandler.loadClass(ContextHandler.java:1517) at org.eclipse.jetty.webapp.StandardDescriptorProcessor.visitListener(StandardDescriptorProcessor.java:1839) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.eclipse.jetty.webapp.IterativeDescriptorProcessor.visit(IterativeDescriptorProcessor.java:80) at org.eclipse.jetty.webapp.IterativeDescriptorProcessor.process(IterativeDescriptorProcessor.java:67) at org.eclipse.jetty.webapp.MetaData.resolve(MetaData.java:332) at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1219) at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:710) at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:454) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:229) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95) at org.eclipse.jetty.server.Server.doStart(Server.java:280) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.wst.server.preview.internal.PreviewStarter.run(PreviewStarter.java:72) at org.eclipse.wst.server.preview.internal.PreviewStarter.main(PreviewStarter.java:29) 2014-01-16 20:13:02.931:WARN:oejs.Holder: java.lang.ClassNotFoundException: org.springframework.web.filter.HiddenHttpMethodFilter at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:424) at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:377) at org.eclipse.jetty.util.Loader.loadClass(Loader.java:100) at org.eclipse.jetty.util.Loader.loadClass(Loader.java:79) at org.eclipse.jetty.servlet.Holder.doStart(Holder.java:97) at org.eclipse.jetty.servlet.FilterHolder.doStart(FilterHolder.java:91) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:719) at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:265) at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1221) at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:710) at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:454) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:229) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95) at org.eclipse.jetty.server.Server.doStart(Server.java:280) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.wst.server.preview.internal.PreviewStarter.run(PreviewStarter.java:72) at org.eclipse.wst.server.preview.internal.PreviewStarter.main(PreviewStarter.java:29) 2014-01-16 20:13:02.932:WARN:oejuc.AbstractLifeCycle:FAILED httpMethodFilter: javax.servlet.UnavailableException: org.springframework.web.filter.HiddenHttpMethodFilter javax.servlet.UnavailableException: org.springframework.web.filter.HiddenHttpMethodFilter at org.eclipse.jetty.servlet.Holder.doStart(Holder.java:104) at org.eclipse.jetty.servlet.FilterHolder.doStart(FilterHolder.java:91) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:719) at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:265) at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1221) at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:710) at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:454) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:229) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95) at org.eclipse.jetty.server.Server.doStart(Server.java:280) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.wst.server.preview.internal.PreviewStarter.run(PreviewStarter.java:72) at org.eclipse.wst.server.preview.internal.PreviewStarter.main(PreviewStarter.java:29) 2014-01-16 20:13:02.933:WARN:oejw.WebAppContext:Failed startup of context o.e.j.w.WebAppContext{/petclinic,[file:/home/szilard/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/spring-petclinic/, jar:file:/home/szilard/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/spring-petclinic/WEB-INF/lib/jquery-2.0.3-1.jar!/META-INF/resources/, jar:file:/home/szilard/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/spring-petclinic/WEB-INF/lib/jquery-ui-1.10.3.jar!/META-INF/resources/, jar:file:/home/szilard/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/spring-petclinic/WEB-INF/lib/bootstrap-2.3.0.jar!/META-INF/resources/]},/home/szilard/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/spring-petclinic javax.servlet.UnavailableException: org.springframework.web.filter.HiddenHttpMethodFilter at org.eclipse.jetty.servlet.Holder.doStart(Holder.java:104) at org.eclipse.jetty.servlet.FilterHolder.doStart(FilterHolder.java:91) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:719) at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:265) at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1221) at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:710) at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:454) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:229) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95) at org.eclipse.jetty.server.Server.doStart(Server.java:280) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.wst.server.preview.internal.PreviewStarter.run(PreviewStarter.java:72) at org.eclipse.wst.server.preview.internal.PreviewStarter.main(PreviewStarter.java:29) 2014-01-16 20:13:03.416:WARN:oejw.StandardDescriptorProcessor:Could not instantiate listener org.springframework.web.context.ContextLoaderListener java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:424) at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:377) at org.eclipse.jetty.server.handler.ContextHandler.loadClass(ContextHandler.java:1517) at org.eclipse.jetty.webapp.StandardDescriptorProcessor.visitListener(StandardDescriptorProcessor.java:1839) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.eclipse.jetty.webapp.IterativeDescriptorProcessor.visit(IterativeDescriptorProcessor.java:80) at org.eclipse.jetty.webapp.IterativeDescriptorProcessor.process(IterativeDescriptorProcessor.java:67) at org.eclipse.jetty.webapp.MetaData.resolve(MetaData.java:332) at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1219) at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:710) at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:454) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:229) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95) at org.eclipse.jetty.server.Server.doStart(Server.java:280) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.wst.server.preview.internal.PreviewStarter.run(PreviewStarter.java:72) at org.eclipse.wst.server.preview.internal.PreviewStarter.main(PreviewStarter.java:29) 2014-01-16 20:13:03.431:WARN:oejs.Holder: java.lang.ClassNotFoundException: org.springframework.web.filter.DelegatingFilterProxy at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:424) at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:377) at org.eclipse.jetty.util.Loader.loadClass(Loader.java:100) at org.eclipse.jetty.util.Loader.loadClass(Loader.java:79) at org.eclipse.jetty.servlet.Holder.doStart(Holder.java:97) at org.eclipse.jetty.servlet.FilterHolder.doStart(FilterHolder.java:91) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:719) at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:265) at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1221) at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:710) at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:454) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:229) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95) at org.eclipse.jetty.server.Server.doStart(Server.java:280) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.wst.server.preview.internal.PreviewStarter.run(PreviewStarter.java:72) at org.eclipse.wst.server.preview.internal.PreviewStarter.main(PreviewStarter.java:29) 2014-01-16 20:13:03.432:WARN:oejuc.AbstractLifeCycle:FAILED csrfFilter: javax.servlet.UnavailableException: org.springframework.web.filter.DelegatingFilterProxy javax.servlet.UnavailableException: org.springframework.web.filter.DelegatingFilterProxy at org.eclipse.jetty.servlet.Holder.doStart(Holder.java:104) at org.eclipse.jetty.servlet.FilterHolder.doStart(FilterHolder.java:91) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:719) at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:265) at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1221) at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:710) at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:454) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:229) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95) at org.eclipse.jetty.server.Server.doStart(Server.java:280) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.wst.server.preview.internal.PreviewStarter.run(PreviewStarter.java:72) at org.eclipse.wst.server.preview.internal.PreviewStarter.main(PreviewStarter.java:29) 2014-01-16 20:13:03.432:WARN:oejw.WebAppContext:Failed startup of context o.e.j.w.WebAppContext{/spring-mvc-showcase,file:/home/szilard/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/spring-mvc-showcase/},/home/szilard/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/spring-mvc-showcase javax.servlet.UnavailableException: org.springframework.web.filter.DelegatingFilterProxy at org.eclipse.jetty.servlet.Holder.doStart(Holder.java:104) at org.eclipse.jetty.servlet.FilterHolder.doStart(FilterHolder.java:91) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:719) at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:265) at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1221) at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:710) at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:454) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:229) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95) at org.eclipse.jetty.server.Server.doStart(Server.java:280) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.wst.server.preview.internal.PreviewStarter.run(PreviewStarter.java:72) at org.eclipse.wst.server.preview.internal.PreviewStarter.main(PreviewStarter.java:29) 2014-01-16 20:13:03.485:INFO:oejs.AbstractConnector:Started [email protected]:8080

4

4 Answers

1
votes

You mentioned the Spring MVC Showcase as the project you are trying to run. I recommend running from the terminal before trying to build and run in Eclipse. This eliminates any issues you may have with your Eclipse environment. The readme on the github page says to run the following command:

mvn tomcat7:run

The app will build and deploy to a Tomcat 7 instance. You'll see this in the terminal. Once it starts, you can access the showcase app at the following URL:

http://localhost:8080/spring-mvc-showcase/

I just tried these steps and was able to successfully view the showcase app in my browser. After you verify that you can run the app from the terminal, then you can try deploying it to Tomcat inside of Eclipse.

0
votes

Check if the project are under maven.

pack the project using the follow command.

mvn clean package

than try run again.

0
votes

It all depends on the nature of your project...if that is a a maven project you should

  • have those dependencies in compile
  • have war as packaging

The pom editor in eclipse is your friend for making sure both points

If is a wtp project the build path settings change between eclipse versions

However...the final result must be the same: check the built war and make sure those libraries are in WEB-INF/lib

-1
votes

If the project is not built by maven and is a simple eclipse dynamic web project, try doing this

If exists, delete the .snap file located in the directory <workspace-directory>\.metadata\.plugins\org.eclipse.core.resources

After deleting this file, you could start Eclipse with no problem.

If not, delete tmp0 (name may vary to tmp) folder in the following directory <workspace-directory>\.metadata\.plugins\org.eclipse.wst.server.core

If there is any problem on deleting this folder then restart your eclipse then again delete that folder.