Error mvn clean package Test openmrs-core

Hi everyone,

I’m currently working on a project for my university course, and I recently cloned the OpenMRS repository (master branch) to run some tests and experiment with the platform.

However, when I attempt to build the project using JDK 8 and Maven 3.8.8, I encounter the following error during the test phase:

kotlin

Copiar código

java.lang.NoClassDefFoundError: Could not initialize class org.openmrs.api.context.Context


[ERROR] Tests run: 60, Failures: 0, Errors: 19, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for OpenMRS 2.7.0-SNAPSHOT:
[INFO]
[INFO] OpenMRS ............................................ SUCCESS [  2.784 s]
[INFO] openmrs-tools ...................................... SUCCESS [  0.981 s]
[INFO] openmrs-test ....................................... SUCCESS [  0.257 s]
[INFO] openmrs-api ........................................ SUCCESS [07:32 min]
[INFO] openmrs-web ........................................ FAILURE [ 10.054 s]
[INFO] openmrs-webapp ..................................... SKIPPED
[INFO] openmrs-liquibase .................................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  07:46 min
[INFO] Finished at: 2024-10-20T21:51:02Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.5.1:test (default-test) on project openmrs-web:
[ERROR]

I’ve made sure that my environment is set up correctly, but I’m not sure why this error is occurring. Has anyone faced a similar issue or have any suggestions on how to resolve it?

Thanks in advance for your help!

Best regards, Francis Tena

What does this command return? mvn -v?

Apache Maven 3.8.8 Maven home: /usr/share/maven Java version: 1.8.0_422, vendor: Private Build, runtime: /usr/lib/jvm/java-8-openjdk-amd64/jre

Run mvn clean install

Yes, I ran that and the response was the failed tests.

Can you share the full build log via pastebin.com?

Hi! Yes, This is the log: openMrsCore - Pastebin.com

Does it make any difference if you upgrade your Java version to the latest in the 1.8 line?

Same error with java version 1.8.0_431

@dkayiwa,

These errors that @francistena1992 is reporting

[ERROR] org.openmrs.web.filter.update.GZIPFilterTest.zipRequestWrapperTest_shouldReturnTrueIfUnzippedContentReadFromWrapperIsTheSameAsContentBeforeZipping -- Time elapsed: 0.004 s <<< ERROR!
java.lang.NoClassDefFoundError: Could not initialize class org.openmrs.api.context.Context
        at org.openmrs.util.OpenmrsUtil.getApplicationDataDirectoryAsFile(OpenmrsUtil.java:977)
        at org.openmrs.util.OpenmrsUtil.getApplicationDataDirectory(OpenmrsUtil.java:965)
        at org.openmrs.test.TestUtil.getRuntimeProperties(TestUtil.java:86)
        at org.openmrs.test.jupiter.BaseContextSensitiveTest.getRuntimeProperties(BaseContextSensitiveTest.java:306)
        at org.openmrs.test.jupiter.BaseContextSensitiveTest.<init>(BaseContextSensitiveTest.java:199)
        at org.openmrs.web.test.BaseWebContextSensitiveTest.<init>(BaseWebContextSensitiveTest.java:30)
        at org.openmrs.web.filter.update.GZIPFilterTest.<init>(GZIPFilterTest.java:40)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at java.util.Optional.orElseGet(Optional.java:267)
        at java.util.ArrayList.forEach(ArrayList.java:1259)
        at java.util.ArrayList.forEach(ArrayList.java:1259)
 
[ERROR] org.openmrs.web.filter.update.GZIPFilterTest -- Time elapsed: 0.282 s <<< ERROR!
java.lang.NoClassDefFoundError: Could not initialize class org.openmrs.api.context.Context
        at org.openmrs.test.jupiter.BaseContextSensitiveTest.closeSessionAfterEachClass(BaseContextSensitiveTest.java:1026)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at java.util.ArrayList.forEach(ArrayList.java:1259)
        at java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1082)
        at java.util.ArrayList.forEach(ArrayList.java:1259)
 
[INFO] Running org.openmrs.web.filter.update.util.FilterUtilTest
[ERROR] Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 0.034 s <<< FAILURE! -- in org.openmrs.web.filter.update.util.FilterUtilTest

Looks very much like the errors you mentioned that are showing on some of the CI builds for OpenMRS core. You thought there was a pattern of the tests passing on one CI worker but consistently failing on the others. I took a quick look at disk space and it appeared very similar across the Bamboo workers. Given the similar error is happening for people locally (and Wikum mentioned he has seen it on GitHub actions), it suggests the problem may not be specific to the Bamboo agents.

I think @wikumc was referring to another type of error on github actions. Not this one.

@burke this is the interesting pattern, if you rerun opemrs-core’s bamboo CI build for the master branch, on the agent named yu.openmrs.org, it will pass. But it will fail for each of the remaining two agents xindi.openmrs.org and xiao.openmrs.org. And this happens consistently. I mean that the passing on yu and failing on xindi and xiao does not happen randomly, it is 100 consistent. Leading me to think that those two agents on which it fails have an environment attribute similar to what @francistena1992 has, that triggers it. And that is what i am trying to find out. :slight_smile:

@francistena1992 can you run this command? git reset HEAD~47

Then run again mvn clean install and tell us if you still get this error.

Hi! I done that, but I receive another error. This is the log: openMrsCore - Pastebin.com