1

我刚刚使用 Spring Template for MVC 创建的全新项目。我尝试在服务器上运行并获得以下信息。

有任何想法吗?

SEVERE: ContainerBase.addChild: start: 
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/src]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618)
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:650)
    at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1582)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContextException
    at java.lang.Class.getDeclaredFields0(Native Method)
    at java.lang.Class.privateGetDeclaredFields(Class.java:2291)
    at java.lang.Class.getDeclaredFields(Class.java:1743)
    at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:87)
    at org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:261)
    at org.apache.catalina.startup.WebAnnotationSet.loadApplicationListenerAnnotations(WebAnnotationSet.java:90)
    at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:65)
    at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:405)
    at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:881)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:369)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5173)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 11 more
Caused by: java.lang.ClassNotFoundException: org.springframework.context.ApplicationContextException
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
    ... 25 more
Jan 15, 2013 10:27:41 AM org.apache.catalina.startup.HostConfig deployDescriptor
SEVERE: Error deploying configuration descriptor /Users/maratlevit/springsource/vfabric-tc-server-developer-2.7.2.RELEASE/base-instance/conf/Catalina/localhost/src.xml
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/src]]
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:904)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618)
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:650)
    at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1582)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:680)

编辑:查看标记选项卡,我看到以下内容:

Description Resource    Path    Location    Type
Archive for required library: '/Users/maratlevit/.m2/repository/org/springframework/spring-aop/3.1.1.RELEASE/spring-aop-3.1.1.RELEASE.jar' in project 'FirstLesson' cannot be read or is not a valid ZIP file   FirstLesson     Build path  Build Path Problem

编辑 2:根据要求添加了依赖项列表:

/Users/maratlevit/.m2/repository/org/springframework/spring-context/3.1.1.RELEASE/spring-context-3.1.1.RELEASE.jar
/Users/maratlevit/.m2/repository/org/springframework/spring-aop/3.1.1.RELEASE/spring-aop-3.1.1.RELEASE.jar
/Users/maratlevit/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar
/Users/maratlevit/.m2/repository/org/springframework/spring-beans/3.1.1.RELEASE/spring-beans-3.1.1.RELEASE.jar
/Users/maratlevit/.m2/repository/org/springframework/spring-core/3.1.1.RELEASE/spring-core-3.1.1.RELEASE.jar
/Users/maratlevit/.m2/repository/org/springframework/spring-expression/3.1.1.RELEASE/spring-expression-3.1.1.RELEASE.jar
/Users/maratlevit/.m2/repository/org/springframework/spring-asm/3.1.1.RELEASE/spring-asm-3.1.1.RELEASE.jar
/Users/maratlevit/.m2/repository/org/springframework/spring-webmvc/3.1.1.RELEASE/spring-webmvc-3.1.1.RELEASE.jar
/Users/maratlevit/.m2/repository/org/springframework/spring-context-support/3.1.1.RELEASE/spring-context-support-3.1.1.RELEASE.jar
/Users/maratlevit/.m2/repository/org/springframework/spring-web/3.1.1.RELEASE/spring-web-3.1.1.RELEASE.jar
/Users/maratlevit/.m2/repository/org/aspectj/aspectjrt/1.6.10/aspectjrt-1.6.10.jar
/Users/maratlevit/.m2/repository/org/slf4j/slf4j-api/1.6.6/slf4j-api-1.6.6.jar
/Users/maratlevit/.m2/repository/org/slf4j/jcl-over-slf4j/1.6.6/jcl-over-slf4j-1.6.6.jar
/Users/maratlevit/.m2/repository/org/slf4j/slf4j-log4j12/1.6.6/slf4j-log4j12-1.6.6.jar
/Users/maratlevit/.m2/repository/log4j/log4j/1.2.15/log4j-1.2.15.jar
/Users/maratlevit/.m2/repository/javax/inject/javax.inject/1/javax.inject-1.jar
/Users/maratlevit/.m2/repository/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar
/Users/maratlevit/.m2/repository/javax/servlet/jsp/jsp-api/2.1/jsp-api-2.1.jar
/Users/maratlevit/.m2/repository/javax/servlet/jstl/1.2/jstl-1.2.jar
/Users/maratlevit/.m2/repository/junit/junit/4.7/junit-4.7.jar
4

3 回答 3

2

我要检查的第一件事是:

项目 -> 右键单击​​ -> 属性 -> Java 构建路径 -> 库 -> 确保“Maven 依赖项”在该列表中。

第二次测试:

项目 -> 右键单击​​ -> 属性 -> 部署程序集 -> 确保“Maven 依赖项”在该列表中作为源。然后,确保其对应的 Deploy Path 正确。我通常将我的部署路径设为 {project}/src/main/webapp/WEB-INF/lib

希望能帮助到你。

于 2013-01-15T00:28:23.117 回答
0

需要更具体的信息:它是一个 Maven 项目吗?所有 jar 都添加到项目中了吗?

可能导致 ClassNotFound异常的因素:

  1. jar 未添加到WEB-INF/lib目录中

  2. 在 web.xml 中未正确配置 DispatcherServlet 引用

能否上传web.xml、spring xml、项目结构并验证以上信息?

于 2013-01-14T23:42:51.157 回答
0

很可能您的类路径设置正确,这就是您获得ClassNotFoundException.

检查它的正确性,并且所有的罐子都在正确的位置。

于 2013-01-14T23:44:03.457 回答