在开发过程中,我使用tomcat插件来实现maven:tomcat7-maven-plugin 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)
有更多错误,但所有上述类型的错误。
答案 0 :(得分:2)
通过安装tomcat v 7.0.53
解决答案 1 :(得分:1)
我猜你正在构建一个基于JEE 7规范的Web应用程序,我可以看到WebSocket api,而你的依赖是针对JEE 6.为JEE 7添加正确的依赖项,错误将被删除。该错误是由于它无法找到该类。由于依赖性不匹配,它也显示版本不匹配错误。