java-ContextLoaderListener问题
作者:互联网
我正在研究将Spring和Apache Camel一起使用的教程,但是spring配置存在一些问题.我围绕ContextLoaderListener不断收到错误,但是我不确定是什么问题.我之前已经做过简单的Spring应用程序,并且我相信我的web.xml布局正确,但是无论如何我都不是专家.
如果有人知道解决此错误的方法,这样我实际上可以运行我的项目,这将对您非常有帮助,那么我会在下面提供web.xml和错误/堆栈的副本.谢谢!
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
<display-name>Archetype Created Web Application</display-name>
<!-- the listener that kick-starts Spring -->
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<!-- location of spring xml files -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:camel-config.xml</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation1</param-name>
<param-value>classpath:cxf-config.xml</param-value>
</context-param>
<!-- CXF servlet -->
<servlet>
<servlet-name>CXFServlet</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- all our webservices are mapped under this URI pattern -->
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/webservices/*</url-pattern>
</servlet-mapping>
Could not instantiate listener org.springframework.web.context.ContextLoaderListender
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListender
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 org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:392)
at runjettyrun.ProjectClassLoader.loadClass(ProjectClassLoader.java:89)
at org.mortbay.jetty.handler.ContextHandler.loadClass(ContextHandler.java:1102)
at org.mortbay.jetty.webapp.WebXmlConfiguration.initListener(WebXmlConfiguration.java:630)
at org.mortbay.jetty.webapp.WebXmlConfiguration.initWebXmlElement(WebXmlConfiguration.java:368)
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:1279)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:518)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:499)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
at org.mortbay.jetty.Server.doStart(Server.java:224)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at runjettyrun.Bootstrap.main(Bootstrap.java:97)
2013-01-16 01:45:03.468:WARN::failed CXFServlet: java.lang.NoClassDefFoundError: org/springframework/web/context/WebApplicationContext
2013-01-16 01:45:03.468:WARN::failed org.mortbay.jetty.webapp.WebAppContext@2aa49512{/camel-example-reportincident,C:\Users\patrick.archambeau\workspace\ApacheCamelTesting\camel-example-reportincident\src\main\webapp}: java.lang.NoClassDefFoundError: org/springframework/web/context/WebApplicationContext
2013-01-16 01:45:03.468:WARN::Error starting handlers
java.lang.NoClassDefFoundError: org/springframework/web/context/WebApplicationContext
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2404)
at java.lang.Class.getConstructor0(Class.java:2714)
at java.lang.Class.newInstance0(Class.java:343)
at java.lang.Class.newInstance(Class.java:325)
at org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:153)
at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:428)
at org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:263)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:736)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1282)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:518)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:499)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
at org.mortbay.jetty.Server.doStart(Server.java:224)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at runjettyrun.Bootstrap.main(Bootstrap.java:97)
解决方法:
java.lang.NoClassDefFoundError:org / springframework / web / context / WebApplicationContext告诉您在类路径中缺少WebApplicationContext类.此类在spring-web.jar中找到.因此,要解决此问题,请将spring-web添加到您的类路径中.
标签:apache-camel,spring,java 来源: https://codeday.me/bug/20191031/1975347.html