I’ve mentioned in some calls in the past some issues we’ve been having deploying the FHIR 2 module to some versions of OpenMRS. I’ve written up a ticket for it here with some of the details. I’ll be adding comments as I reconstruct the various things I’ve tried. If anyone has any insight into how to get Spring injection working in a Java Servlet, that would be very welcome!
Nothing strikes me off-hand. Since it is working in the SDK but not outside the SDK, I’d probably recommend getting set up outside of the SDK (eg. using a dockerized tomcat), and starting tomcat with the appropriate arguments to expose the Debug port, and then put some breakpoints in and see what is happening.
Thanks Mike! Yeah, I’ve been trying that with no real success (I keep getting lost deep in the bowels of Spring).
Spring expects the
javax.inject.Inject class to be loaded by the same class loader as the one which loaded the ‘Spring classes’, i would suggest that you change the fhir2 module’s
javax.inject dependency to
<scope>provided</scope>. Then put the
javax.inject dependency in the OpenMRS core platform. For all environments where this problem does not happen, it means that they already had the ‘javax.inject.Inject’ class in the class path, which was then loaded by the class loader that loads
The other alternative would be to simply replace
@ibacher do you have any objections to this proposal?
No, not at all. I had reasons for favouring
@Autowired, but that can be undone. I’m more concerned with the continuing issues I was seeing after manually loading the
Inject annotation, but maybe that will go away if we use
The downside of using
@Inject is that the module would require at least maintenance versions of the openmrs platform that have got the
javax.inject dependency. But with
@Autowired, all will be well with what you already support.