1

这可能以前被问过,但他们都没有解决我的问题

我已经制作了一个 servlet,我想将它托管在 tomcat7 中。 当我使用 eclipse 在 tomcat7 中运行 servlet 时,它运行得很好(在服务器上运行)

echo $CATALINA_HOME 是/usr/share/tomcat7

但是webapp 文件夹位于 /var/lib/tomcat7

我使用 eclipse[ file->export->web->war ]制作了一个战争文件

错误

11 Sep, 2013 12:30:51 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
11 Sep, 2013 12:30:51 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.26
11 Sep, 2013 12:30:51 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor /etc/tomcat7/Catalina/localhost/host-manager.xml
11 Sep, 2013 12:30:58 AM org.apache.catalina.util.SessionIdGenerator createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [6,114] milliseconds.
11 Sep, 2013 12:30:58 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor /etc/tomcat7/Catalina/localhost/manager.xml
11 Sep, 2013 12:30:58 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /var/lib/tomcat7/webapps/sms.war
11 Sep, 2013 12:30:58 AM org.apache.catalina.core.ContainerBase addChildInternal
SEVERE: ContainerBase.addChild: start: 
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/sms]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:958)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1599)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:679)
Caused by: java.lang.UnsupportedClassVersionError: org/raxa/module/handlesms/IncomingSMS : Unsupported major.minor version 51.0 (unable to load class org.raxa.module.handlesms.IncomingSMS)
    at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2840)
    at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1160)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1668)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
    at org.apache.catalina.startup.WebAnnotationSet.loadApplicationServletAnnotations(WebAnnotationSet.java:108)
    at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:58)
    at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:381)
    at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:858)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:345)
    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:5161)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 11 more
11 Sep, 2013 12:30:58 AM org.apache.catalina.startup.HostConfig deployWAR
SEVERE: Error deploying web application archive /var/lib/tomcat7/webapps/sms.war
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/sms]]
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:898)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:958)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1599)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:679)
11 Sep, 2013 12:30:58 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /var/lib/tomcat7/webapps/sample.war
11 Sep, 2013 12:30:58 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /var/lib/tomcat7/webapps/ROOT
11 Sep, 2013 12:30:59 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
11 Sep, 2013 12:30:59 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 7455 ms

我也尝试使用 apache ant 创建战争文件,但它给出了同样的错误。

在eclipse中,我提供了tomcat安装目录是/usr/share/tomcat7,即$catalina_home

java版本

java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)

SOLUTION 设置tomcat java_home 为系统java-version

教程:设置tomcat7的java_home的链接

4

1 回答 1

2

实际上,您的异常的要点是 java.lang.UnsupportedClassVersionError Unsupported major.minor version 51.0
这意味着至少必须使用 java 7 才能启动 tomcat。

你应该检查你启动tomcat的jdk。
肯定它比 java 7 低。没有必要匹配 java -version 返回

为了更深入地了解 java.lang.UnsupportedClassVersionError:http:
//javarevisited.blogspot.ch/2011/07/javalangunsupportedclassversionerror.html

于 2013-09-10T20:15:52.887 回答