Running Rep App 2.12.x with OpenMRS 2.6.x

Has anyone tried running the latest 2.x version of the reference app (2.12.2) with the latest master line of OpenMRS Core (2.6.0-SNAPSHOT)?

I just installed a new 2.12.2 Ref App distro via the SDK and then deployed the latest Core build from master and restarted.

I’m seeing the error in the logs during startup:

INFO - ServiceContext.startRefreshingContext(838) |2022-07-26T14:35:41,676| Refreshing Context
java.lang.IllegalStateException: Filters cannot be added to context [/openmrs] as the context has been initialised
	at org.apache.catalina.core.ApplicationContext.addFilter(ApplicationContext.java:795)
	at org.apache.catalina.core.ApplicationContext.addFilter(ApplicationContext.java:773)
	at org.apache.catalina.core.ApplicationContextFacade.addFilter(ApplicationContextFacade.java:457)
	at org.openmrs.web.WebComponentRegistrar.setServletContext(WebComponentRegistrar.java:39)
	at org.springframework.web.context.support.ServletContextAwareProcessor.postProcessBeforeInitialization(ServletContextAwareProcessor.java:108)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:440)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
	at org.openmrs.module.ModuleUtil.refreshApplicationContext(ModuleUtil.java:885)
	at org.openmrs.module.web.WebModuleUtil.refreshWAC(WebModuleUtil.java:923)
	at org.openmrs.web.Listener.performWebStartOfModules(Listener.java:655)
	at org.openmrs.web.Listener.performWebStartOfModules(Listener.java:635)
	at org.openmrs.web.Listener.startOpenmrs(Listener.java:303)
	at org.openmrs.web.WebDaemon$1.run(WebDaemon.java:42)
INFO - ServiceContext.doneRefreshingContext(849) |2022-07-26T14:36:04,509| 

OpenMRS appears to start after that, but when I try to go to “/openmrs” I get a 404 error and see the following in the logs:

WARN - DispatcherServlet.noHandlerFound(1281) |2022-07-26T14:37:31,643| No mapping for GET /openmrs/

I could research further, but wanted to check if this was a “known issue” first… apologies if I missed past discussion, I’ve been out of pocket for a few months.

fyi @dkayiwa @ibacher @mseaton

Thanks all! Mark

Hmmm… I confirmed that I have the same problem when running the PIH EMR distro against the latest Core, but in that caes I am not seeing the first error message posted above, so that error could be a red herring.

Which version of tomcat are you running? It looks related to this: [TRUNK-6086] Core on Tomcat 9.x and RA 2.6.x not starting up - OpenMRS Issues

And does this work? ....openmrs/index.htm

@dkayiwa thanks for pointing out the ticket, that does seem to be the behavior I’m seeing… I’m using Apache Tomcat/9.0.52, which is what the SDK appears to using by default.

“openmrs/index.htm” does work, but then when I try to log in I get the following error:

" Invalid or Missing CSRF Token. Try Going Back and Refresh the page after clearing the browser cache. [Back]"

Will try downgrading Tomcat.

Ah, I was looking to see if there was way to configure which version of Tomcat the SDK used, but I’m seeing:

tomcat7-maven-plugin contains the code to run OpenMRS in an embedded Tomcat 7 instance. This is used for serving SDK versions running parts of the platform prior to 2.5.0.

tomcat9-maven-plugin contains the code to run OpenMRS in an embedded Tomcat 9 instance. This is used for serving SDK versions running platform 2.5.0 or newer.

You can either disable CSRF protection by looking for this file in your openmrs application data folder and change this value https://github.com/openmrs/openmrs-core/blob/master/webapp/src/main/webapp/WEB-INF/csrfguard.properties#L46 to false

Or add the csrfguard script to your page as done here: csrfguard or here: TRUNK-6051 adding CsrfGuard script tag · openmrs/openmrs-module-legacyui@c4b8e31 · GitHub

1 Like

That did it, thanks @dkayiwa !

I had to add the csrfguard line to our login gsp.

Also, we weren’t running the latest appui snapshot (which you had added that line to the standard 2.x lab page). I’m going to go ahead and release App UI to get that change into a released version. (it will be the only thing in since the last release).