Friday, January 17, 2020

Maven compilation asm issue: nested exception is java.lang.IncompatibleClassChangeError: class org.springframework.core.type.classreading.ClassMetadataReadingVisitor has interface org.springframework.asm.ClassVisitor as super class




>PROBLEM


A deployable file is created using:

  mvn clean install


Attempt to run fails:

  java -jar myfile.war

generating the following message (snippets):

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: URL 
[jar:file:/L:/work/dev/java/projects/tpzapp/parent/sisgit2/sisgit2-2.0.war!/WEB-INF/classes!/br/net/telespazio/sisgit2/app/Sisgit2App.class]; 
nested exception is java.lang.IncompatibleClassChangeError: class org.springframework.core.type.classreading.ClassMetadataReadingVisitor has interface org.springframework.asm.ClassVisitor as super class
 at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:311) ~[spring-context-4.3.9.RELEASE.jar!/:4.3.9.RELEASE]
 at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:272) ~[spring-context-4.3.9.RELEASE.jar!/:4.3.9.RELEASE]
 at org.springframework.context.annotation.ComponentScanAnnotationParser.parse(ComponentScanAnnotationParser.java:135) ~[spring-context-4.3.9.RELEASE.jar!/:4.3.9.RELEASE]
...
Caused by: java.lang.IncompatibleClassChangeError: class org.springframework.core.type.classreading.ClassMetadataReadingVisitor has interface org.springframework.asm.ClassVisitor as super class
 at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_112]
 at java.lang.ClassLoader.defineClass(ClassLoader.java:763) ~[na:1.8.0_112]
 at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.8.0_112]



>SOLUTION


Switched maven's compilation plugins configuration as follows:


>>BEFORE


<packaging>war</packaging>
<plugin>
<groupid>org.springframework.boot</groupid>
<artifactid>spring-boot-maven-plugin</artifactid>
</plugin>
<plugin>
<groupid>org.apache.maven.plugins</groupid>
<artifactid>maven-surefire-plugin</artifactid>
</plugin>

         

>>AFTER


<packaging>jar</packaging>
<plugin>
<groupid>org.springframework.boot</groupid>
<artifactid>spring-boot-maven-plugin</artifactid>
</plugin>


>ENV

Windows 10
Java 8
Maven 3.x

No comments:

Post a Comment

eclipse: java: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder" or Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder

  >PROBLEM Using Eclipse, you try to run a simple logging test using "org.slf4j.Logger" like the sample below: package Test; im...