'Configure DHIS2 Connection' page crashes when trying to connect to an instance

Tags: #<Tag:0x00007fa3f0b25778>

Hi all, The following error occurs when trying to connect to a DHIS2 instance. The same error occurs when trying to test the connection too. See attached gifs.

I’ve created an issue on Jira : https://issues.openmrs.org/browse/DRM-46

org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.LinkageError: loader constraint violation: when resolving method "org.apache.http.protocol.HttpCoreContext.<init>(Lorg/apache/http/protocol/HttpContext;)V" the class loader (instance of org/openmrs/module/ModuleClassLoader) of the current class, org/apache/http/client/protocol/HttpClientContext, and the class loader (instance of org/codehaus/plexus/classworlds/realm/ClassRealm) for the method's defining class, org/apache/http/protocol/HttpCoreContext, have different Class objects for the type org/apache/http/protocol/HttpContext used in the signature
	org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1287)
	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:961)
	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
	org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
	org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
	org.openmrs.module.web.filter.ForcePasswordChangeFilter.doFilter(ForcePasswordChangeFilter.java:60)
	org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:72)
	org.openmrs.module.owa.filter.OwaFilter.doFilter(OwaFilter.java:57)
	org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:70)
	org.openmrs.module.web.filter.ModuleFilter.doFilter(ModuleFilter.java:54)
	org.openmrs.web.filter.OpenmrsFilter.doFilterInternal(OpenmrsFilter.java:108)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:150)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:105)
	org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:105)
	org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:105)
	org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
Root Cause

java.lang.LinkageError: loader constraint violation: when resolving method "org.apache.http.protocol.HttpCoreContext.<init>(Lorg/apache/http/protocol/HttpContext;)V" the class loader (instance of org/openmrs/module/ModuleClassLoader) of the current class, org/apache/http/client/protocol/HttpClientContext, and the class loader (instance of org/codehaus/plexus/classworlds/realm/ClassRealm) for the method's defining class, org/apache/http/protocol/HttpCoreContext, have different Class objects for the type org/apache/http/protocol/HttpContext used in the signature
	org.apache.http.client.protocol.HttpClientContext.<init>(HttpClientContext.java:151)
	org.apache.http.client.protocol.HttpClientContext.adapt(HttpClientContext.java:142)
	org.apache.http.client.protocol.RequestClientConnControl.process(RequestClientConnControl.java:71)
	org.apache.http.protocol.ImmutableHttpProcessor.process(ImmutableHttpProcessor.java:109)
	org.apache.http.protocol.HttpRequestExecutor.preProcess(HttpRequestExecutor.java:176)
	org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:485)
	org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863)
	org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
	org.openmrs.module.dhisreport.web.controller.Dhis2ServerController.testConnection(Dhis2ServerController.java:225)
	org.openmrs.module.dhisreport.web.controller.Dhis2ServerController.CheckConnectionWithDHIS2(Dhis2ServerController.java:133)
	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	java.lang.reflect.Method.invoke(Method.java:498)
	org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:177)
	org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:446)
	org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:434)
	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943)
	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
	org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
	org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
	org.openmrs.module.web.filter.ForcePasswordChangeFilter.doFilter(ForcePasswordChangeFilter.java:60)
	org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:72)
	org.openmrs.module.owa.filter.OwaFilter.doFilter(OwaFilter.java:57)
	org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:70)
	org.openmrs.module.web.filter.ModuleFilter.doFilter(ModuleFilter.java:54)
	org.openmrs.web.filter.OpenmrsFilter.doFilterInternal(OpenmrsFilter.java:108)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:150)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:105)
	org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:105)
	org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:105)
	org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

Connecting to an instance:

Testing Connection:

I managed to fix this issue by bumping the httpclient and httpcore modules to the latest versions.

I sent a PR, please review and merge:

Thanks for sharing the fix to your own problem. :slight_smile:

1 Like

You are welcome @dkayiwa! :innocent: