ASM ClassReader failed to parse class file- probably due to a new Java class file version that isn't supported yet问题

出错情况:由于接口的更改,在工程中更新了一个外部依赖的jar包,在编译启动后遇到了下述问题:

Caused by: org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a newJava class file version that isn‘t supported yet: URL [jar:file:/D:/project/extra-v20171116/extra/extra-interfaces/target/extra/WEB-INF/lib/seat-api-1.0.jar!/com/csair/extra/seat/controller/paramswrapper/FlightChangeReqParam.class];nested exception is java.lang.IllegalArgumentException

排错:根据probably due to a new Java class file version that isn‘t supported yet这条提示消息,感觉可能是jdk的匹配问题。

然后我查看了一下项目工程所使用的jdk版本。----在项目的pom文件中

				<!-- maven 编译版本使用jdk1.7 -->
				<plugin>
					<artifactId>maven-compiler-plugin</artifactId>
					<version>3.1</version>
					<configuration>
						<source>1.7</source>
						<target>1.7</target>
						<encoding>UTF-8</encoding>
					</configuration>
				</plugin>

          然后查看一下jar包中报错的FlightChangeReqParam.class的编译版本。通过IDEA直接按住ctrl键点进去看,IDEA会直接帮我们反编译的。

可以看到这是jdk1.8版本下编译的。所以确实是跟当前的工程不匹配的。应该只要重新打个1.7版本的jar包就不会报错了。

试着在网上查找一下更深层次的原因。

If you encounter this error even if you compile with -target 1.7, please note that this is because of a bug in Spring Frameworkwhich causes ASM classreader to load jdk classes (java.* or javax.*), which are, of course, compiled with -target 1.8.
This, combined with the old ASM version in spring 3.2.8 and below, which does not support parsing of 1.8 class files, can also lead to this error.
This should be fixed in Spring Framework version 3.2.9, which is due to be released soon.
Of course, upgrading to Spring Framework 4 will also resolve the issue, as it already contains a newer version of ASM.

原因:所以其实是Spring3.2.8版本及其以下不支持编译版本为JDK1.8的jar包。如果想要用1.8版本的jar包,那么就得更新到Spring 4。

             要么就只有全使用编译版本为JDK1.7的jar包。

总结: 这里还有一个需要注意的地方就是,编译和运行是两个分开的动作。即编译和运行可以使用不同版本的jdk.

但是需要注意的是:运行的jdk版本不能低于编译时的版本。

           这是因为IDEA中我的jdk版本是1.8的,但是在此之前都是能运行这个工程的。这个不会对工程有影响的。

由于这是个大工程,有很多人一起开发,因此配置是必须保持稳定的,所以这种情况只能去重修对class文件进行编译。

下次在引入别人包的时候是需要谨慎的,稍不注意,后续的排错,更改是非常耗时耗力的。不过在职业前期累计错误也好,之后看到错误就直到“对症下药”了。

ASM ClassReader failed to parse class file- probably due to a new Java class file version that isn't supported yet问题

时间: 2024-08-03 21:40:28

ASM ClassReader failed to parse class file- probably due to a new Java class file version that isn't supported yet问题的相关文章

ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn

错误产生的信息如下: Caused by: org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: file [E:\develop_tools\apache-tomcat-8.0.18\webapps\SpringMVCUpload

Spring MVC 单元测试异常 Caused by: org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file

Sping 3.2.8.RELEASE + sping mvc + JDK 1.8运行异常. java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:99) at org.springfr

ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn&#39;t supported yet

1. 问题描述 tomcat启动项目 报错如上,ide是eclipse,jdk安装的是jdk8. 2. 解决方案 可能原项目是用jdk7或其他版本开发的,错误提示也很清晰,更换jdk编译一下 项目右键-->build path-->Configure build path-->Project facets 再重新发布 启动好了 ASM ClassReader failed to parse class file - probably due to a new Java class fil

Caused by: org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file

最近在琢磨maven,自己照着网上的例子塔了一个例子,在junit测试时报错了,详细错误信息: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [D:\workspace\MAVEN\example_1\target\classes\cn\springmvc\service\impl\UserServiceImpl.clas

SpringMVC 异常信息ASM ClassReader failed to parse class file的问题解决

1.  环境信息: Spring 3.2.0,  JDK 1.8.0 2.  运行简单的程序,出现以下错误信息: 2.  运行简单的程序,出现以下错误信息: Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [D:\NewWorkSpace\ep-user\target\test-classes\org\

Java 关于File使用

1. File类 1.1. File类说明 存储在变量,数组和对象中的数据是暂时的,当程序终止时他们就会丢失.为了能够永 久的保存程序中创建的数据,需要将他们存储到硬盘或光盘的文件中.这些文件可以移动,传送,亦可以被其他程序使用.由于数据存储在文件中,所以我们需要学习一个和文件有密切关系的类,叫做File类,将要掌握获取文件的属性以及删除和重命名文件.最终如何向文件中写入数据和从文件中读取数据. 那么File类关心的是在磁盘上文件的存储. File类描述的是一个文件或文件夹.(文件夹也可以称为目

【Java】File.createTempFile创建临时文件

API参数: /** fileName: 临时文件的名字, 生成后的文件名字将会是[fileName + 随机数] suffix: 文件后缀,例如.txt, .tmp parentFile: 临时文件目录,如果不指定,则默认把临时文件存储于系统临时文件目录上        */ public static File createTempFile(String fileName,                       String suffix,                       

ssh整合context:component-scan包名写了*号:Failed to parse configuration class [org.springframework.cache.aspectj.AspectJJCacheConfiguration]

1 2 3 4 03-Apr-2016 00:27:57.154 WARNING [RMI TCP Connection(3)-127.0.0.1] org.springframework.web.context.support.XmlWebApplicationContext.refresh Exception encountered during context initialization - cancelling refresh attempt: org.springframework.

处理 javax.el.ELException: Failed to parse the expression 报错

在JSP的表达式语言中,使用了  <h3>是否新Session:${pageContext.session.new}</h3>  输出Session是否是新的,此时遇到了  javax.el.ELException: Failed to parse the expression  报错.这里主要是因为在Tomcat7中表达式的权限变小了,如果遇到JAVA的关键字,就会出现此种错误,在这个例子中就是因为 new 是JAVA的关键字,所以才会出错. 解决办法:设置启动参数   -Dor