欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

java.lang.UnsupportedClassVersionError问题调试

程序员文章站 2022-05-14 18:58:02
...
java.lang.UnsupportedClassVersionError: com/sand/mcs/pub/core/Publish : Unsupported major.minor version 51.0 (unable to load class com.sand.mcs.pub.core.Publish)
        at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2908)
        at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1173)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1681)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
        at com.sand.smp.server.core.util.CT.<clinit>(CT.java:610)
        at com.sand.smp.server.core.svc.MutilChannelHelpSvc.calMonitor(MutilChannelHelpSvc.java:86)
        at com.sand.smp.server.core.svc.impl.MutilChannelSvcImpl.walletStatQuery(MutilChannelSvcImpl.java:2869)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
        at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)
        at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:91)
        at com.sand.smp.server.core.monitor.MonitorAspect.doAround(MonitorAspect.java:28)
        at sun.reflect.GeneratedMethodAccessor127.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)


看报错信息,是因为使用的jar包版本不对。这个51.0是什么呢?

  JDK不同的版本,编译出的class文件是不同的。通过查看分析class文件前几个字节,可以找到对应的关系,详细的参考官方,细微的版本之间可能有差异:
J2SE 7 = 51 (0x33 hex),
J2SE 6.0 = 50 (0x32 hex),
J2SE 5.0 = 49 (0x31 hex),
JDK 1.4 = 48 (0x30 hex),
JDK 1.3 = 47 (0x2F hex),
JDK 1.2 = 46 (0x2E hex),
JDK 1.1 = 45 (0x2D hex).


查看jar包的配置文件:

java.lang.UnsupportedClassVersionError问题调试
            
    
    博客分类: 工作心得 java.lang.UnsupportedClassVersionErrormaven打war问题 

解决方式:
修改项目编译jre版本为1.7.0_79,重新打war包发布,问题解决。
  • java.lang.UnsupportedClassVersionError问题调试
            
    
    博客分类: 工作心得 java.lang.UnsupportedClassVersionErrormaven打war问题 
  • 大小: 68.4 KB