在tomcat6中运行此项目时出错

时间:2011-01-12 11:59:18

标签: spring tomcat

当我使用tomcat6在myeclipse中运行我的项目时,它会抛出一个错误,所以我应该怎么做关于spring类的错误但是我将从myeclipse加载所有spring库

Jan 12, 2011 5:24:09 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre1.6.0\bin;C:\Program Files\Genuitec\Common\plugins\com.genuitec.eclipse.easie.tomcat.myeclipse_8.6.0.me201007231647\tomcat\bin
Jan 12, 2011 5:24:10 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Jan 12, 2011 5:24:10 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 2559 ms
Jan 12, 2011 5:24:10 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Jan 12, 2011 5:24:10 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.13
Jan 12, 2011 5:24:19 PM org.apache.catalina.loader.WebappLoader start
SEVERE: LifecycleException 
java.lang.ClassNotFoundException: org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader
    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 java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at org.apache.catalina.loader.WebappLoader.createClassLoader(WebappLoader.java:770)
    at org.apache.catalina.loader.WebappLoader.start(WebappLoader.java:639)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4196)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
    at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(StandardService.java:516)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Jan 12, 2011 5:24:19 PM org.apache.catalina.core.ContainerBase addChildInternal
SEVERE: ContainerBase.addChild: start: 
LifecycleException:  start: :  java.lang.ClassNotFoundException: org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader
    at org.apache.catalina.loader.WebappLoader.start(WebappLoader.java:676)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4196)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
    at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(StandardService.java:516)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Jan 12, 2011 5:24:19 PM org.apache.catalina.startup.HostConfig deployDirectory
SEVERE: Error deploying web application directory servlet
java.lang.IllegalStateException: ContainerBase.addChild: start: LifecycleException:  start: :  java.lang.ClassNotFoundException: org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:795)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
    at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(StandardService.java:516)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Jan 12, 2011 5:24:19 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Jan 12, 2011 5:24:20 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Jan 12, 2011 5:24:20 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/219  config=null
Jan 12, 2011 5:24:20 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 9998 ms

4 个答案:

答案 0 :(得分:1)

答案 1 :(得分:0)

您的Tomcat已配置为使用Spring的类加载器检测框架,但类路径中缺少Spring。

您需要删除该检测配置,或将Spring添加到类路径中。

答案 2 :(得分:0)

似乎其中一个Spring jar不在你的类路径上。

答案 3 :(得分:0)

这个问题很难回答而不需要更多细节......我在不同情况下遇到了这个(或类似的)错误,其中一个问题刚刚解决了。

如果您使用Eclipse的“Run as / Run on Server”命令/菜单运行应用程序,那么您可以尝试手动将spring-instrument-tomcat-.jar添加到Tomcat的安装home / lib /目录中,然后再试一次;或者(如果你实际上不需要LTW或检测) - 检查你的项目中是否有loaderClass =“org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader”.webapp / META-INF / context.xml并将其删除。

如果您实际上正在使用Maven并从eclipse运行“Run As / Maven ...”(那么 - tomcat6:run命令;也可以从控制台执行),那么这是一个不同的故事。以下POM配置适用于在独立tomcat上部署(如果您已按上述方法添加了spring JAR)和嵌入式tomcat: ...

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <webResources>
                    <resource>
                        <targetPath>META-INF</targetPath>
                        <directory>src/main/config</directory>
                        <includes>
                            <include>context.xml</include>
                        </includes>
                    </resource>
                </webResources>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat6-maven-plugin</artifactId>
            <version>2.0</version>
            <configuration>
                <port>8080</port>
                <path>/</path>                  
                <update>true</update>               
                <classLoaderClass>org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader</classLoaderClass>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-instrument-tomcat</artifactId>
                    <version>${spring.version}</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>

注意:TomcatInstrumentableClassLoader和META-INF / context.xml文件与tomcat6-maven-plugin(当context.xml文件不在src / main / webapp / META-INF / context.xml中时有效) ,所以我不得不把它移到src / main / config然后让maven-war-plugin来处理它。

干杯, IR。