Week 7 - Dependency Issues 2/2

After I hadn’t made any progress comparing openmrs and optaplanner dependencies, I decided to debug the entire optaplanner initialization process in order to find the difference between running standalone and inside openmrs. I found some dissimilarities inside Parser.class. This class should be imported from ecj-3.7.2.jar Again I checked the dependencies of openmrs with the command

mvn dependency:tree

but couldn’t find this particular library in the resulting output. In a next step I wanted to figure out, where Parser.class is loaded from. Therefore I inserted the following code snippet and redeployed my module to openmrs:

Class klass = org.eclipse.jdt.internal.compiler.parser.Parser.class;
URL location = klass.getResource('/' + klass.getName().replace('.', '/') + ".class");
System.err.println(location);

Alternatively you can use the vm option -verbose:class

The output told me that this class has been loaded from:

/home/lukas/.m2/repository/org/eclipse/jdt/core/3.1.1/core-3.1.1.jar

It turned out that the jetty maven plugin imports this library. As a quick fix I updated this plugin inside openmrs-core/webapp/pom.xml and the exception vanished. A better solution would be to force the modules class loader to look for classes in the modules classpath first. I will discuss that on openmrs talk.