Cohort Builder Error

When going to cohort builder, unable to access it getting the following error: An Internal Error has Occurred java.lang.IllegalArgumentException Comparison method violates its general contract

Possibly related, this error was found within a day after using metadata sharing to bring order sets to the server using Order Extension Module.

That same error was received by one user ordering one of the order sets that was imported using metadata sharing.

The cohort builder error also showed up on another server that is was synced with using Sync module.

Possibly related, a few servers within a day of this had issues with submitting forms where the form would say “You must log in again before the form can be submitted” even though the user was logged in. This particular issue appeared to be solved by restarting the server.

Server details: Server version: Apache Tomcat/7.0.62 Server built: May 7 2015 17:14:55 UTC Server number: OS Name: Linux OS Version: 3.13.0-101-generic Architecture: amd64 JVM Version: 1.7.0_80-b15 JVM Vendor: Oracle Corporation

java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15) Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)

The stack trace follows An Internal Error has Occurred java.lang.IllegalArgumentException Comparison method violates its general contract!

Consult the help document. Contact your friendly neighborhood administrator if it cannot be resolved.

Hide stack trace java.util.TimSort.mergeHi( java.util.TimSort.mergeAt( java.util.TimSort.mergeForceCollapse( java.util.TimSort.sort( java.util.TimSort.sort( java.util.Arrays.sort( java.util.Collections.sort( org.openmrs.web.controller.analysis.CohortBuilderController.handleRequest( org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle( org.springframework.web.servlet.DispatcherServlet.doDispatch( org.springframework.web.servlet.DispatcherServlet.doService( org.springframework.web.servlet.FrameworkServlet.processRequest( org.springframework.web.servlet.FrameworkServlet.doGet( javax.servlet.http.HttpServlet.service( javax.servlet.http.HttpServlet.service( org.apache.catalina.core.ApplicationFilterChain.internalDoFilter( org.apache.catalina.core.ApplicationFilterChain.doFilter( org.apache.tomcat.websocket.server.WsFilter.doFilter( org.apache.catalina.core.ApplicationFilterChain.internalDoFilter( org.apache.catalina.core.ApplicationFilterChain.doFilter( org.openmrs.module.web.filter.ForcePasswordChangeFilter.doFilter( org.apache.catalina.core.ApplicationFilterChain.internalDoFilter( org.apache.catalina.core.ApplicationFilterChain.doFilter( org.openmrs.module.web.filter.ModuleFilterChain.doFilter( org.springframework.web.filter.RequestContextFilter.doFilterInternal( org.openmrs.module.usagestatistics.web.filter.RequestProviderFilter.doFilterInternal( org.springframework.web.filter.OncePerRequestFilter.doFilter( org.openmrs.module.web.filter.ModuleFilterChain.doFilter( org.openmrs.module.web.filter.ModuleFilter.doFilter( org.apache.catalina.core.ApplicationFilterChain.internalDoFilter( org.apache.catalina.core.ApplicationFilterChain.doFilter( org.openmrs.web.filter.OpenmrsFilter.doFilterInternal( org.springframework.web.filter.OncePerRequestFilter.doFilter( org.apache.catalina.core.ApplicationFilterChain.internalDoFilter( org.apache.catalina.core.ApplicationFilterChain.doFilter( org.springframework.web.filter.OncePerRequestFilter.doFilter( org.apache.catalina.core.ApplicationFilterChain.internalDoFilter( org.apache.catalina.core.ApplicationFilterChain.doFilter( org.openmrs.web.filter.StartupFilter.doFilter( org.apache.catalina.core.ApplicationFilterChain.internalDoFilter( org.apache.catalina.core.ApplicationFilterChain.doFilter( org.openmrs.web.filter.StartupFilter.doFilter( org.apache.catalina.core.ApplicationFilterChain.internalDoFilter( org.apache.catalina.core.ApplicationFilterChain.doFilter( org.openmrs.web.filter.StartupFilter.doFilter( org.apache.catalina.core.ApplicationFilterChain.internalDoFilter( org.apache.catalina.core.ApplicationFilterChain.doFilter( org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal( org.springframework.web.filter.OncePerRequestFilter.doFilter( org.apache.catalina.core.ApplicationFilterChain.internalDoFilter( org.apache.catalina.core.ApplicationFilterChain.doFilter( org.apache.catalina.core.StandardWrapperValve.invoke( org.apache.catalina.core.StandardContextValve.invoke( org.apache.catalina.authenticator.AuthenticatorBase.invoke( org.apache.catalina.core.StandardHostValve.invoke( org.apache.catalina.valves.ErrorReportValve.invoke( org.apache.catalina.valves.AccessLogValve.invoke( org.apache.catalina.core.StandardEngineValve.invoke( org.apache.catalina.connector.CoyoteAdapter.service( org.apache.coyote.http11.AbstractHttp11Processor.process( org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process($ java.util.concurrent.ThreadPoolExecutor.runWorker( java.util.concurrent.ThreadPoolExecutor$ org.apache.tomcat.util.threads.TaskThread$

OpenMRS Version: 1.9.11 Build cdfdaa

Our best hypotheses center around java versions (which we can’t figure out how they would have changed) or the metadata share of the order set (though the interaction is non obvious). Furthermore, the fundamental error may be related to the following issue outside OpenMRS

Is it possible to post the entire log at

The link above that @toddandersonpih shared is not the issue, but I found it and shared it because it seemed to indicate that this error can manifest when there is a fatal error inside of the sort method (i.e. this may have nothing to do with a sort method violating it’s general contract, but rather that might be the error that gets thrown inadvertently when some other fatal condition occurs).

Our best guess right now is that there is a bad hibernate error (lazy loading probably) happening when fetching concept names (this is something that seems to happen a lot), and this is what is causing the error. That would also explain why a metadata import caused this to start happening. So I think we should pursue this line of investigation and see if we can find something amiss with those concepts that would cause the system to fail when loading them.

Incidentally, and not entirely related (but related in that it will be hard to fix this for Rwanda in the master branch) - I notice that we increased the minimum OpenMRS version requirement of cohort builder to the 2.x line a while back. What would we have done this? Given that this is a legacy module and we are actively trying to work on a newer alternative, making this module no longer compatible with legacy implementations running older versions of core seems like the wrong approach. @dkayiwa / @raff / @wyclif / @darius, thoughts on this? Is this something that we can reverse?

Thanks, Mike

Update: @jberchmas found a drug with a NULL name that was brought over from the metadata share. When this was given a name, the cohort builder error disappeared.

Thanks for the interest Todd

@mseaton assuming you are referring to the reporting compatibility module, a number of classes were moved from the core platform to this module hence requiring a lot of work to have the same module running on both platform 2.x and lower versions. This was coupled with the fact this module is eventually getting deprecated (not much more active development going into it besides a few bug fixes). Basing on that background, the easiest fix was to have a 1.x branch for those running on platform 1.x

@dkayiwa - thanks, that does make sense. I remember this now.

I think I was confused because I noticed that the latest 1.x-compatible version in the module repository was 1.5.8 and put there almost 5 years ago :slight_smile: The head of the 1.x branch in github is at 1.5.12-SNAPSHOT. So it seems that we are not doing a very good job of ensuring that the module repository is updated when we do a new release. Luckily, the design of the new add-on-index is such that this will be a concern of the past very soon :slight_smile: