Can a module have it's own database configs different from core?

Hi all

I have task of implementing a fhir jpa server from within the radiology module. Here is the tutorial I’m using It uses this example Following the tutorial and the example code I was able to create a fhir server from scratch as a separate web app(i.e not with radiology). Here is my code It has it’s database configurations in this file And inside the web.xml it references that config file

How can I do something similar from within the radiology module and still deploy it to openmrs. It configures it’s own application context inside the web.xml. Also I need to declare some servlets(spring dispatcher and fhir servlet) with their own mappings. OpenMRS modules don’t have a web.xml file. How can I achieve this?

It would be nice if the FHIR module could be extended to support other modules (like this one), so modules could leverage a growing & increasingly robust FHIR base and focus on their needs.

/cc @harsha89 @surangak

1 Like

@ivange94, this wiki page describes how to define a module in a servlet: (@wyclif is this page still up-to-date? Does Platform 2.0 + the newer servlet spec mean we have a new preferred way for modules to define servlets?)

Though the servlet spec has a way of dynamically defining servlets, as used here: it has a disadvantage of working only the first time OpenMRS is started. That is when you add it with any call that originated from when the servlet context is being initialised. Any other times, like during module restarts, it will always fail with a stack trace like below:

java.lang.IllegalStateException: Started at org.eclipse.jetty.servlet.BaseHolder.illegalStateIfContextStarted( at org.eclipse.jetty.servlet.ServletHolder$Registration.addMapping( at org.openmrs.web.WebComponentRegistrar.addMappings( at org.openmrs.web.WebComponentRegistrar.setServletContext(

What the above exception means is that, it is illegal to do so after the servlet context was already initialised and started.

In summary, our custom module servlet strategy is, for now, the best and hence recommended.

@dkayiwa thanks for this summary!

I assumed that we used this new dynamic way in the legacyui module because the old Module Servlet approach was insufficient for some reason. Is there a limitation on the old way, such that sometimes you’re required to do the new way?

Oh, I see from the wiki page that the limitation of the Module Servlets is that they can’t support wildcard URIs.

(I have updated the wiki docs to also mention the alternative way Daniel shared.)

@burke Yes. We will need to brainstorm on how we can integrate other modules. Currently FHIR depends on some modules which uses those module APIs to support resources.

Thanks, Harsha