When you run OpenMRS platform 2.0 on apache tomcat 7.0.26 with the legacyui module installed, OpenMRS fails to run, with the error message below:
org.openmrs.api.APIException: A user context must first be passed to setUserContext()…use Context.openSession() (and closeSession() to prevent memory leaks!) before using the API org.openmrs.api.context.Context.getUserContext(Context.java:236) org.openmrs.api.context.Context.getAuthenticatedUser(Context.java:595) org.openmrs.api.context.Context.isAuthenticated(Context.java:605) org.openmrs.module.web.filter.ForcePasswordChangeFilter.doFilter(ForcePasswordChangeFilter.java:55) note The full stack trace of the root cause is available in the Apache Tomcat/7.0.26 logs.
This is caused by tomcat calling the dynamically registered ForcePasswordChangeFilter before the OpenmrsFilter which is supposed to set the user context.
It took me a while to figure this out because it was not happening locally, and i believe this is a bug in this version of tomcat. The solution was to upgrade to a newer version of tomcat. Am sharing here for the sake of those who may encounter this while trying out platform 2.0