我得到的是:
java.lang.NoClassDefFoundError: com/mongodb/DB
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
at java.lang.Class.getDeclaredMethods(Class.java:1791)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:446)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:430)
at org.springframework.util.ReflectionUtils.getAllDeclaredMethods(ReflectionUtils.java:475)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:634)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:573)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1319)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:315)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:394)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:594)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:407)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:442)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:458)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:339)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:306)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4420)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4733)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
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(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
此类位于maven jar内(来自M2存储库)。我将Maven Dependencies添加到DeploymentAssembly(在我做之前我得到了:java.lang.ClassNotFoundException:org.springframework.web.filter.CharacterEncodingFilter)。我使用m2e插件并将我的项目配置为Maven项目。我的应用程序部署到标准位置/.metadata/.plugins/.../tmp0。在WEB-INF / lib里面我有所有必要的罐子。项目编译没有错误。我能做错什么?
一个准解决方案是向Tomcat lib目录添加必要的库,但我不想这样做。我想强制Tomcat使用项目库。
答案 0 :(得分:6)
我在尝试运行 mcv-ajax 和 mvc-basic 示例时出现了类似的问题,这些示例随 Spring 3 一起发布(两者都有)可以在https://src.springframework.org/svn/spring-samples获得 - 需要SVN客户端下载它们,比如TortoiseSVN。
我在Tomcat6启动日志中收到了这个ClassNotFoundException。
SEVERE: Exception starting filter characterEncodingFilter java.lang.ClassNotFoundException: org.springframework.web.filter.CharacterEncodingFilter
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.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:269)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4071)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4725)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
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(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Feb 17, 2012 10:36:18 AM org.apache.catalina.core.StandardContext start
SEVERE: Error filterStart
Feb 17, 2012 10:36:18 AM org.apache.catalina.core.StandardContext start
SEVERE: Context [/mvc-basic] startup failed due to previous errors
我可以运行Maven Clean和Maven Install目标,没有错误,并且项目没有任何类路径错误。 我还按照指示here在 Maven Integration for Eclipse Extras 包下安装了eclipse Maven Integration for WTP ,但仍然没有运气......
我的案例中的问题可以在Eclipse的标记标签中看到,作为警告(黄色标记),其中包含 Classpath依赖关系验证器消息的描述 并且不会导出或发布类路径条目org.eclipse.maven2_classpath.container的实际问题。可能会导致运行时ClassNotFoundExceptions。
解决此问题
结论 上面介绍的步骤对我来说非常有效,可以让我的项目在我的Eclispe开发环境中成功运行。请试一试,看看它是否适合您。
另一种似乎也起作用的解决方案是
亲切的问候,
ta6hbe
答案 1 :(得分:0)
看起来你没有安装m2eclipse WTP集成。
如果是这样,那么这可能是我错误部署的根源。安装WTP集成时您不需要在部署描述符中更改任何内容 - 插件应自动配置您的项目。如果没有,请尝试RMB - &gt; Maven - &gt;更新项目配置,但请务必先安装WTP集成。