Filters and/or Servlets cannot be added to context [/openmrs] as the context has been initialised

Does this happen only when these two modules are used together? In other words, can i assume that if I use any of the two modules then i do not get any errors?

TRUNK-6169 happens only when OpenMRS is started from the InitializationFilter or the UpdateFilter. For other times where things work well, OpenMRS is started from our servlet context Listener. And the reason why it works from our servlet context listener is simply because by then, the web application initialisation process, in the context of the servlet container, is just starting and hence, still allowed to dynamically register filters and servlets. When setting up a new instance of OpenMRS or when doing an upgrade, our listener does not start OpenMRS but instead just sets a flag that we need to run the set up wizard. This then triggers the InitializationFilter or UpdateFilter as needed, when anyone tries to access OpenMRS.

Based on this, it will be easier for us to just do TRUNK-4673 by adding support for init parameters for servlets such that devs can continue using our custom servlet registration mechanism.

2 Likes