In OpenMRS, there is 3 places where the webapp and spring web application context are initialized i.e. the web Listener, InitializationFilter and UpdateFilter. You can't load module resources on OpenMRS installation or Upgrade unless you explicitly use the OpenMRS classloader, this can lead to obscure bugs unknowingly. Both the listener and the filters start OpenMRS in a daemon thread but the filters spawn the daemon thread before setting the OpenMRS classloader instance on the current thread which is the reason why module resources can't be loaded during initialization and upgrade. In theory bugs caused by this only show up after installation and upgrade but on subsequent restarts of OpenMRS they go away.
- Update the filters to set the Openmrs classloader on the current thread before starting OpenMRS and the spring web application context that way it is inherited by the daemon thread.