Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven-scr-plugin fails with SCRDescriptorException "unable to scan files ... Class file format probably not supported by ASM ?"

Using the following dependencies (amongst others, the bundle is supposed to be installed to AEM 6.1)

runtime is java8

  • maven-scr-plugin 1.15.0
  • org.apache.felix.scr.annotations: 1.9.8
  • org.apache.felix.scr.ds-annotations: 1.2.8

I get this exception

Caused by: org.apache.felix.scrplugin.SCRDescriptorException: Unable to scan class files: ... (Class file format probably not supported by ASM ?) at org.apache.felix.scrplugin.helper.ClassScanner.processClass(ClassScanner.java:219) at org.apache.felix.scrplugin.helper.ClassScanner.process(ClassScanner.java:161) at org.apache.felix.scrplugin.helper.ClassScanner.scanSources(ClassScanner.java:146) at org.apache.felix.scrplugin.SCRDescriptorGenerator.execute(SCRDescriptorGenerator.java:146) at org.apache.felix.scrplugin.mojo.SCRDescriptorMojo.execute(SCRDescriptorMojo.java:221) ... 22 more

Caused by: java.lang.IllegalArgumentException at org.objectweb.asm.ClassReader.(Unknown Source) at org.objectweb.asm.ClassReader.(Unknown Source) at org.objectweb.asm.ClassReader.(Unknown Source) at org.apache.felix.scrplugin.helper.ClassScanner.processClass(ClassScanner.java:201)

The class in question does not contain any osgi annotations at all, but is merely imported in some other @Component annotated classes.

Did anyone encounter this and found a solution?

like image 243
lain Avatar asked Oct 20 '15 14:10

lain


1 Answers

I ran into this issue today. This happens when you are running maven-scr-plugin with scanClasses=true option. Older versions of maven-scr-plugin cannot scan classfile generated by java8. you will have to either switch to a newer version of scr plugin (I upgraded to 1.22) or set you maven-compiler-plugin target config to 1.7

like image 190
awd Avatar answered Oct 05 '22 09:10

awd