Jetty, Spring, Run problem

2020-07-20 05:21发布

问题:

Hi im trying to run a webapp, using spring and jetty and the following error is display:

   2011-02-03 10:40:59.398::INFO:  jetty-6.1.6
   2011-02-03 10:41:00.637::WARN:  Could not instantiate listener         org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:375)
    at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:337)
    at org.mortbay.jetty.handler.ContextHandler.loadClass(ContextHandler.java:1013)
    at org.mortbay.jetty.webapp.WebXmlConfiguration.initListener(WebXmlConfiguration.java:629)
    at org.mortbay.jetty.webapp.WebXmlConfiguration.initWebXmlElement(WebXmlConfiguration.java:367)
    at org.mortbay.jetty.webapp.WebXmlConfiguration.initialize(WebXmlConfiguration.java:289)
    at org.mortbay.jetty.webapp.WebXmlConfiguration.configure(WebXmlConfiguration.java:222)
    at org.mortbay.jetty.webapp.WebXmlConfiguration.configureWebApp(WebXmlConfiguration.java:180)
    at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1213)
    at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:509)
    at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:447)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:117)
    at org.mortbay.jetty.Server.doStart(Server.java:222)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
    at runjettyrun.Bootstrap.main(Bootstrap.java:121)
2011-02-03 10:41:00.962::INFO:  Started SelectChannelConnector@0.0.0.0:8080

any idea? thanks

回答1:

Yes, you don't have the correct Spring JARs on your classpath.

ContextLoaderListener is in org.springframework.web.servlet-3.0.x.RELEASE.jar.



回答2:

Strangely, this error can also occur when using the jetty-maven-plugin version 7.5.3 or higher with maven2 (instead of maven 3).

See also: http://wiki.eclipse.org/Jetty/Feature/Jetty_Maven_Plugin and http://martingreber.wordpress.com/2011/11/05/spring-maven-jetty-exception/



标签: spring Jetty