I’ve been working on the module and all of a sudden now it won’t get loaded. The error says it’s a class loader constraint violation.
Previously, the module could be loaded to the Ref App 2.6 through the web interface. OpenMRS refreshed context and loaded classes without any problem.
But once I shut down the server, restarting it would throw an error saying the following:
… nested exception is java.lang.LinkageError: loader constraint violation: loader (instance of org/openmrs/util/OpenmrsClassLoader) previously initiated loading for a different type with name "org/joda/time/DateTime"
The full stack trace is in this paste : upload_error_jodaTime - Pastebin.com
Apparently, the class loader encounters a conflict with multiple Joda time versions. However, I could delete the module from the server’s folder manually, start the server and then load the module via the web interface for testing.
The class loader constraint violation would come up whenever I restarted the server.
But this week, I could not load the module even in a fresh server. When I load the module via the web interface, the server would crash while refreshing the server. The error is the same.
I looked at other modules using the Joda time library - EMR API and Reporting. I tried the following so far;
So far, not so good. The error’s still there and I found this on Stack Overflow - Spring java.lang.LinkageError: loader constraint violation: loader previously initiated loading for a different type with name X - Stack Overflow
But that wasn’t exactly applicable to this instance.
Next step was checking if Joda time dependency could be fully replaced with Java time available in Java 8. I started doing this but Java Time is not a full replacement for Joda time. Some features such as intervals do not have equivalents in Java time.
The best move as I see it would be continuing to use the latest version of Joda Time by eliminating the class loading error. This should be possible as the other modules work together without any problem. It’d be better to use a tried and tested (and already implemented) library than come up with a hasty replacement.
Any help is welcome