I am running the module against OpenMRS 1.11.4 on Tomcat 7 and Ubuntu 15.10 and here is my pom file :
Whenever I install/update the module, Context.getService({Any service in my module}.class) returns null and throws an APIException stating that the service was not found. This however gets fixed on restarting tomcat. I’d assume that OpenMRS was not able to find the openmrs-module-radiology-fhir-support-api.jar in the /lib folder (which is present) and therefore restarting tomcat reloads the application container and refreshes the classpath.
After this, whenever I execute any Service Layer method that uses dom4j api, I get a
java.lang.NoClassDefFoundError: org/jaxen/JaxenException . Here are the logs
Here are the methods that use the dom4j API :
I understand this error means that JaxenException is not on my classpath. To confirm this, I performed the following steps:
mvn package the module. Go to /omod/taget and confirmed that the module’s omod file contains jaxen-1.1.6.jar in the /lib subdirectory.
I extracted that jaxen-1.1.6.jar and it did contain /org/jaxen.JaxenException.class ruling out possibility of an invalid jar file
I verified that module’s omod is present in /var/lib/OpenMRS/modules/ contains jaxen-1.1.6.jar in the /lib subdirectory
I cannot figure out why jaxen-1.1.6.jar is not on the classpath. and I always get the exact same error after playing around with the pom. The interesting thing is that when the exact same Service Methods are executed in Tests, they run perfectly.
What could I be missing?
To work-around this issue in the most unethical way, I placed the jaxen-1.1.6.jar in /var/lib/tomcat7/webapps/openmrs/WEB-INF/libs and everything in the module works correctly.
Thanks for the recommendations and the links @lluismf
I already have quite some code using Dom4j. When I get some time, I will definitely consider migrating if the jaxen exception persists.
The stack overflow link works. But as mentioned in the second comment to this thread, I have to copy the jar manually, which kinda adds an additional and non-conventional step in the module installation process.
@ssmusoke that gives the same error. In case of using scope as provided, jaxen-1.1.6.jar is not present in the packaged omod file.
When I use compile as the scope, jaxen-1.1.6.jar is present in the omod file. But when module is installed, it does not get copied to /var/lib/tomcat7/webapps/openmrs/WEB-INF/lib/ directory. When I manually place the jar in that directly, it works