java.lang.NoClassDefFoundError: org/openmrs/Allergen on using webservices.rest-2.14 with openmrs 1.x

Tags: #<Tag:0x00007fe6d3986b80>

We are trying to upgrade webservices.rest from 2.12 to 2.14 in Bahmni. The openmrs version that we use is 1.12.x. After upgrade, our tests started to fail saying that it could not find this class org.openmrs.Allergen which was introduced in openmrs 2.x. Also we found the following files - Allergen.java and AllergyReaction.java which were added only for test package and found this comment as well - https://github.com/openmrs/openmrs-module-webservices.rest/blob/2.14/omod/src/test/java/org/openmrs/Allergen.java#L3

Is webservices-rest-2.14 compatible with openmrs 1.x?

I think webservices-rest-2.14 is only compatible with released versions of OpenMRS, the lastest of which is 1.11.6.

If you put this omod version in the running Bahmni application, do things work? (I.e. if the failure only in tests, in which case it might be due to a change in the required maven dependencies or something.)

Generally, web services releases are supposed to work against any modern version of the platform, so if it doesn’t run against 1.12.x that’s a regression.

-Darius (by phone)

I know Daniel has been fixing a few things up recently to work with bleeding edge version of core. Do you know what the deal is with the Allergen class @dkayiwa?

@darius yes the failures are only in tests and when we included webservices rest dependency with classifier as ‘tests’, the tests passed. We included dependency like below:

<dependency> <groupId>org.openmrs.module</groupId> <artifactId>webservices.rest-omod</artifactId> <version>${openMRSWebServicesVersion}</version> <classifier>tests</classifier> <scope>test</scope> </dependency>

1 Like

Great, so just to check, this problem is now solved?

yes it is solved

We’re experiencing this error too. I’ve upgraded the webservices version in bahmni-core from 2.17 to 2.24.0 due to the security threat.

Now a bunch of integration tests are failing with a NoClassDefFoundError. An example of such test is ReferenceDataConceptReferenceTermServiceImplIT. This fails with java.lang.NoClassDefFoundError: org/openmrs/CodedOrFreeText.

According to OpenMRS API Docs, CodedOrFreeText was added in OpenMRS 2.2 but bahmni-core depends on 2.1.1.

I tried the solution provided by @preethi.s above with no success.

I added

<dependency>
    <groupId>org.openmrs.module</groupId>
    <artifactId>webservices.rest-omod</artifactId>
    <version>${openMRSWebServicesVersion}</version>
    <classifier>tests</classifier>
    <scope>test</scope>
</dependency>

In bahmni-core/pom.xml and later bahmni-core/reference-data/pom.xml since all failing tests are coming from the reference-data submodule. But it still didn’t work. Tests still fail with the same error.

cc @binduak @angshuonline @dkayiwa

You can do this temporary workaround https://github.com/openmrs/openmrs-module-idgen/blob/3ce39e786461ffc7b2373c3642eda140e2dc2707/omod/src/test/java/org/openmrs/CodedOrFreeText.java

2 Likes

Is this only relevant to test? or would we get into error during runtime as well?

Only for the test. That is why it is under src/test