org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class

Hi @dkayiwa

It seems I’m encountering an error similar to the one reported in this thread. At-least I know that this error is related to the Java compiler version but failed to figure out how to get over it.

Like I reported in Patient Conditions and Encounters, we need this feature in HFE.

So I created a new sub module(api-2.3) and this depends on core 2.3.1-SNAPSHOT. I’m aware that java 8 support is available when you depend on core 2.x and above,

Adding the compiler plugin pointing to 1.8 source to api-2.3 makes spring fail to build the context in the omod sub module:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>3.8.1</version>
  <configuration>
    <source>1.8</source>
    <target>1.8</target>
  </configuration>
</plugin>

Error:

Caused by: org.springframework.beans.factory.BeanDefinitionStoreException:
  Failed to read candidate component class: file [~/openmrs-module-htmlformentry/api-2.3/target/classes/org/openmrs/module/htmlformentry/ConditionElement.class];
  nested exception is java.lang.ArrayIndexOutOfBoundsException: 32364

Here is the full error log: https://pastebin.com/N0Yuamf0


NB: Here is the commit that has changes you want to look at - https://github.com/samuelmale/openmrs-module-htmlformentry/commit/edf722fe4f77fe6c65e8354e5f5e5ca2212ad953

It’s true that if I forget about using Java 8 compatible code, the error is gone

cc: @mksd, @ibacher