无法加载自定义上下文类

时间:2016-05-11 12:36:38

标签: java eclipse spring tomcat

我的Spring配置有点麻烦。它在独立的Tomcat安装中工作,但是当我尝试在Eclipse中部署到Tomcat容器以进行调试时,我收到以下错误:

2016-05-11 21:58:14,682 [localhost-startStop-1] INFO  web.context.ContextLoader (initWebApplicationContext): Root WebApplicationContext: initialization started
2016-05-11 21:58:14,687 [localhost-startStop-1] ERROR web.context.ContextLoader (initWebApplicationContext): Context initialization failed
org.springframework.context.ApplicationContextException: Failed to load custom context class [com.example.CustomWebAppContext]; nested exception is java.lang.ClassNotFoundException: com.example.CustomWebAppContext
    at org.springframework.web.context.ContextLoader.determineContextClass(ContextLoader.java:469)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:355)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:293)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5003)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5517)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1574)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1564)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: com.example.CustomWebAppContext
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1854)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1703)
    at org.springframework.util.ClassUtils.forName(ClassUtils.java:249)
    at org.springframework.web.context.ContextLoader.determineContextClass(ContextLoader.java:466)
    ... 12 more
May 11, 2016 9:58:14 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.context.ApplicationContextException: Failed to load custom context class [com.example.CustomWebAppContext]; nested exception is java.lang.ClassNotFoundException: com.example.CustomWebAppContext
    at org.springframework.web.context.ContextLoader.determineContextClass(ContextLoader.java:469)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:355)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:293)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5003)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5517)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1574)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1564)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: com.example.CustomWebAppContext
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1854)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1703)
    at org.springframework.util.ClassUtils.forName(ClassUtils.java:249)
    at org.springframework.web.context.ContextLoader.determineContextClass(ContextLoader.java:466)
    ... 12 more

的web.xml

<context-param>
  <param-name>contextClass</param-name>
  <param-value>com.example.CustomWebAppContext</param-value>
</context-param>

我在Eclipse中检查了我的项目的Java Build Path和Deployment Assembly,看起来一切都很好。任何帮助将不胜感激。

0 个答案:

没有答案