java.lang.IllegalStateException: Failed to load ApplicationContext on a Test

Hello,

I am failing to run a simple test, (log here) , this is happening I think due to this exeption

Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: URL [jar:file:/C:/Users/Hugo/.m2/repository/org/openmrs/module/htmlformentryui-api/1.6.1/htmlformentryui-api-1.6.1.jar!/org/openmrs/module/htmlformentryui/HTMLFormEntryUIFrameworkIntegrationActivator.class];

But I use ‘htmlformentry-ui’ in my module and the server it does what i want, but when i created this test… If you happen to get same error or similar please share the solution

Best Regards

Which version of Java are you using to run the test?

its java 1.8

What does this command return? mvn -v

C:\WINDOWS\system32>mvn -v
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512m; support was removed in 8.0
Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d;     2017-10-18T08:58:13+01:00)
Maven home: C:\Program Files\apache-maven-3.5.2-bin\apache-maven-3.5.2\bin\..
Java version: 1.8.0_161, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_161\jre
Default locale: pt_PT, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

i just deleted my mvn folder, and still the same error, btw, I’m extending BaseModuleContextSensitiveTest on my test class, could the error came from here?

Which source and target does your maven-compiler-plugin have in the pom file.

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

And which openmrs platform version is your module referencing?

its reference application 2.8

In your pom file? You could also take a look at this: platform module vs reference application module

on my pom file its 2.4,

        <dependency>
            <groupId>org.openmrs.distro</groupId>
            <artifactId>referenceapplication</artifactId>
            <version>2.4</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>

Did you take a look at the link for the different between openmrs platform and reference application modules?

yeah, platform is just core and the reference application uses the core api through the various modules… I’m missing the point, could you tell me?

So are you now better placed to answer my original question? “And which openmrs platform version is your module referencing?”

I’m sorry but my eyes are still sleeping :sweat_smile:

openmrsPlantaformVersion - 1.11.6

Hopefully you are not deep in a dream! :wink:

So can you change the source and target to 7 and then compile again?

sure, but I got a question, this plugin “maven-compiler-plugin”, its on the omod pom its okay to be in there?

still the same error on running the tests, but cant use that as 7, I’ve got some lambdas on my module so i need java 8

Then your openmrs platform version needs to be 2.0 and above because it is from then that we started supporting java 8

1 Like