Tomcat在运行部署的war文件时会产生异常



在开发过程中,我对maven使用tomcat插件:tomcat7-maven-plugin version 2.2当我将war文件部署到远程主机时,tomcat抛出错误。下面是远程服务器上tomcat的版本:

root@vido:/var/lib/tomcat7/webapps# sh /usr/share/tomcat7/bin/version.sh
Using CATALINA_BASE:   /var/lib/tomcat7
Using CATALINA_HOME:   /usr/share/tomcat7
Using CATALINA_TMPDIR: /var/lib/tomcat7/temp
Using JRE_HOME:        /usr/lib/jvm/java-7-oracle
Using CLASSPATH:       /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar
Server version: Apache Tomcat/7.0.26
Server built:   Apr 1 2013 08:32:04
Server number:  7.0.26.0
OS Name:        Linux
OS Version:     3.8.0-29-generic
Architecture:   amd64
JVM Version:    1.7.0_55-b13
JVM Vendor:     Oracle Corporation

java版本:

root@vido:/var/lib/tomcat7/webapps# java -version 
java version "1.7.0_55"
Java(TM) SE Runtime Environment (build 1.7.0_55-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.55-b03, mixed mode)

这是pom.xml文件的一部分:

    <!-- web sockets -->
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>7.0</version>
        <scope>provided</scope>
    </dependency>
    <!-- servlets -->
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>6.0</version>
        <scope>provided</scope>
    </dependency>

以下是例外:

DEBUG [pool-2-thread-1] (AnnotationAttributesReadingVisitor.java:186) - Failed to class-load type while reading annotation metadata. This is a non-fatal error, but certain annotation metadata may be unavailable.
java.lang.ClassNotFoundException: javax.websocket.server.ServerEndpoint
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
    at org.springframework.core.type.classreading.RecursiveAnnotationAttributesVisitor.visitEnd(AnnotationAttributesReadingVisitor.java:182)
    at org.springframework.asm.ClassReader.readAnnotationValues(ClassReader.java:1788)

DEBUG [pool-2-thread-1] (DefaultListableBeanFactory.java:404) - Ignoring bean class loading failure for bean 'getDataHandler' 
org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [com.vm.controllers.GetDataHandler] for bean with name 'getDataHandler' defined in file [/var/lib/tomcat7/webapps/videomessenger/WEB-INF/classes/com/vm/controllers/GetDataHandler.class]: problem with class file or dependent class; nested exception is java.lang.UnsupportedClassVersionError: com/vm/controllers/GetDataHandler : Unsupported major.minor version 51.0 (unable to load class com.vm.controllers.GetDataHandler)
    at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1330)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:594)
    at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1396)

还有更多的错误,但它们都是上面描述的类型。

安装tomcat v 7.0.53

我猜你正在构建一个基于JEE 7规格的web应用程序,我可以看到WebSocket api,而你的依赖是JEE 6。为JEE 7添加正确的依赖项,错误将被删除。这个错误是由于它无法找到类。由于依赖不匹配,它也显示了版本不匹配错误。

相关内容

  • 没有找到相关文章