当我在apache-tomcat-5.0.28中部署应用程序时,我收到此错误:
Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [/opt/devel/server/apache-tomcat-5.0.28/webapps/appServices/WEB-INF/classes/com/xxx/appServices/services/rest/XResource.class]; nested exception is java.lang.UnsupportedClassVersionError: Bad version number in .class file
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:237)
阅读类似的帖子我发现源java版本和编译器版本存在问题,但是当我执行这些命令时,似乎没有任何问题......
apache-tomcat-5.0.28# java -version
java version "1.5.0_22"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_22-b03)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_22-b03, mixed mode)
apache-tomcat-5.0.28# javac -version
javac 1.5.0_22
#javap -verbose XResource | grep version
minor version: 0
major version: 49
#file XResource.class
XsResource.class: compiled Java class data, version 49.0 (Java 1.5)
在我的pom.xml中,我有:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
和
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
...
<configuration>
...
<source>1.5</source>
<target>1.5</target>
<complianceLevel>1.5</complianceLevel>
</configuration>
知道出了什么问题? 错误可能与XResource.class无关吗?
答案 0 :(得分:0)
尝试清理服务器并在服务器上重新部署应用程序。