0

I've read similar post but still cannot resolve this problem. I am using JDK 8 and Spring 5. So it's not due to version issue.

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [G:\githome\product-aggregation\target\classes\com\roger\product\ipc\viewobject\product\MultiUnitVO.class]; nested exception is java.lang.ArrayIndexOutOfBoundsException: 90
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.scanCandidateComponents(ClassPathScanningCandidateComponentProvider.java:454)
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:316)
at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:275)
at org.springframework.context.annotation.ComponentScanAnnotationParser.parse(ComponentScanAnnotationParser.java:132)
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:288)

Caused by: java.lang.ArrayIndexOutOfBoundsException: 90
at org.springframework.asm.ClassReader.readUTF(ClassReader.java:2646)
at org.springframework.asm.ClassReader.readUTF8(ClassReader.java:2618)
at org.springframework.asm.ClassReader.readMethod(ClassReader.java:1110)
at org.springframework.asm.ClassReader.accept(ClassReader.java:729)
at org.springframework.asm.ClassReader.accept(ClassReader.java:527)
at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:65)
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:103)
at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:123)
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.scanCandidateComponents(ClassPathScanningCandidateComponentProvider.java:430)
... 20 common frames omitted

It's like this. I developed a maven plugin and included it in my project. This plugin is used to generate fields for specific classes in process-classes phase. To achieve this, I used ASM(version 5.0) to modify classes. Maven dependency like this:

<dependencies>
<dependency>
  <groupId>org.apache.maven</groupId>
  <artifactId>maven-plugin-api</artifactId>
  <version>2.0</version>
</dependency>
<dependency>
  <groupId>com.roger</groupId>
  <artifactId>permission</artifactId>
  <version>1.0-SNAPSHOT</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
  <groupId>commons-io</groupId>
  <artifactId>commons-io</artifactId>
  <version>2.6</version>
</dependency>
<dependency>
  <groupId>javassist</groupId>
  <artifactId>javassist</artifactId>
  <version>3.12.1.GA</version>
</dependency>
<dependency>
  <groupId>org.apache.maven.plugin-tools</groupId>
  <artifactId>maven-plugin-annotations</artifactId>
  <version>3.2</version>
  <scope>provided</scope>
</dependency>
<dependency>
  <groupId>org.codehaus.plexus</groupId>
  <artifactId>plexus-utils</artifactId>
  <version>3.0.8</version>
</dependency>
<dependency>
  <groupId>org.ow2.asm</groupId>
  <artifactId>asm</artifactId>
  <version>5.0</version>
</dependency>
<dependency>
  <groupId>org.ow2.asm</groupId>
  <artifactId>asm-tree</artifactId>
  <version>5.0</version>
</dependency>

Then I included it in my project.

 <plugin>
    <groupId>com.roger</groupId>
    <artifactId>authorization-maven-plugin</artifactId>
    <version>1.0-SNAPSHOT</version>
    <executions>
      <execution>
        <id>execution1</id>
        <phase>process-classes</phase>
        <goals>
          <goal>addFieldPermission</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

My project also has indirect dependency on ASM(version 5.0.4). I even upgraded ASM to 5.0.4(same as project), it's still going wrong.

Dependency popup

I doubted that it's due to ASM conflict but have no idea how to fix it. Any idea?

EDIT Seems it has problem with the modified class. I debugged ClassPathScanningCandidateComponentProvider(spring-context-5.0.8) and found that exception thrown from line 430 just for the modified resources(as I said I added some fields in them by maven plugin). But I decompiled the modified classes using javap and found it's valid. I guess there is problem with the modified classes but don't know what's it.

Roger.H
  • 343
  • 1
  • 4
  • 18

2 Answers2

0

As stated in the error log this is clear index out of bound exception.

Caused by: java.lang.ArrayIndexOutOfBoundsException: 90

Alien
  • 15,141
  • 6
  • 37
  • 57
  • 1
    Guess not. Spring ASM was reading MultiUnitVO class and threw this exception. Not programmatic issue. – Roger.H Feb 19 '19 at 09:11
0

Finally I got a temp solution. I made the fields public and removed the methods generated and everything goes well.

The generated methods are the root cause. When I keep only the generated fields, Spring Boot started up successfully. Seems javassist 3.12.1.GA might go wrong with JDK 1.8. I will further investigate.

Roger.H
  • 343
  • 1
  • 4
  • 18