Uploaded image for project: 'OpenMRS Core'
  1. OpenMRS Core
  2. TRUNK-4300

In some scenario the uncaughtException page can throw an exception instead of rendering properly

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: TBD
    • Resolution: Fixed
    • Affects Version/s: OpenMRS 1.9.7
    • Fix Version/s: OpenMRS 1.9.8, Platform 1.10.0
    • Component/s: None
    • Labels:
      None

      Description

      In the Mirebalais distribution of OpenMRS, I can consistently get an ugly stack trace by doing this:

      1. Go to the run/download report page (after running a report)
      2. Log out in another tab (to simulate having the session time out)
      3. Click to download the report

      I get an ugly stack trace like:

      ERROR - RequestContextAwareTag.doStartTag(86) |2014-03-04 12:23:39,504| collection is not associated with any session
      org.hibernate.HibernateException: collection is not associated with any session
              at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:474)
              at org.hibernate.engine.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistenceContext.java:900)
              at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:279)
              at org.hibernate.loader.Loader.doList(Loader.java:2533)
              at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
              at org.hibernate.loader.Loader.list(Loader.java:2271)
              at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:119)
              at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1716)
              at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:347)
              at org.hibernate.impl.CriteriaImpl.uniqueResult(CriteriaImpl.java:369)
              at org.openmrs.api.db.hibernate.HibernateAdministrationDAO.getGlobalPropertyObject(HibernateAdministrationDAO.java:264)
              at org.openmrs.api.db.hibernate.HibernateAdministrationDAO.getGlobalProperty(HibernateAdministrationDAO.java:250)
              at org.openmrs.api.impl.AdministrationServiceImpl.getGlobalProperty(AdministrationServiceImpl.java:648)
              at sun.reflect.GeneratedMethodAccessor348.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
              at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
              at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
              at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
              at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
              at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
              at com.sun.proxy.$Proxy115.getGlobalProperty(Unknown Source)
              at sun.reflect.GeneratedMethodAccessor348.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
              at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
              at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
              at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
              at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
              at org.openmrs.aop.LoggingAdvice.invoke(LoggingAdvice.java:122)
              at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
              at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:50)
              at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
              at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:50)
              at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
              at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
              at com.sun.proxy.$Proxy116.getGlobalProperty(Unknown Source)
              at sun.reflect.GeneratedMethodAccessor348.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
              at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
              at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
              at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
              at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
              at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
              at com.sun.proxy.$Proxy116.getGlobalProperty(Unknown Source)
              at org.openmrs.web.OpenmrsCookieThemeResolver.getDefaultThemeName(OpenmrsCookieThemeResolver.java:46)
              at org.springframework.web.servlet.theme.CookieThemeResolver.resolveThemeName(CookieThemeResolver.java:93)
              at org.springframework.web.servlet.support.RequestContextUtils.getTheme(RequestContextUtils.java:147)
              at org.springframework.web.servlet.support.RequestContext.getTheme(RequestContext.java:328)
              at org.springframework.web.servlet.tags.ThemeTag.getMessageSource(ThemeTag.java:50)
              at org.springframework.web.servlet.tags.MessageTag.resolveMessage(MessageTag.java:193)
              at org.springframework.web.servlet.tags.MessageTag.doStartTagInternal(MessageTag.java:165)
              at org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:79)
              at org.apache.jsp.WEB_002dINF.view.uncaughtException_jsp._jspx_meth_spring_005ftheme_005f0(uncaughtException_jsp.java:608)
              at org.apache.jsp.WEB_002dINF.view.uncaughtException_jsp._jspService(uncaughtException_jsp.java:181)
              at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
              at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
              at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
              at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.openmrs.web.filter.JspClassLoaderFilter.doFilter(JspClassLoaderFilter.java:51)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:70)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:70)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
              at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
              at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
              at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
              at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
              at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
              at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047)
              at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)
              at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
              at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
              at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.openmrs.module.web.filter.ForcePasswordChangeFilter.doFilter(ForcePasswordChangeFilter.java:65)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:76)
              at org.openmrs.module.web.filter.ModuleFilter.doFilter(ModuleFilter.java:58)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.openmrs.web.filter.OpenmrsFilter.doFilterInternal(OpenmrsFilter.java:111)
              at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
              at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:109)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:109)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:109)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
              at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
              at java.lang.Thread.run(Thread.java:662)
      

      The debugger tells me that the root cause of this is when OpenmrsCookieThemeResolver does

      themeName = Context.getAdministrationService().getGlobalProperty(GP_THEME_NAME);
      

      and this prevents us from ever reaching this lne in uncaughtException.jsp

      if (exception instanceof APIAuthenticationException) {
      

      The expected behavior was to be redirected to the login page (and this generally works elsewhere in the system).

      Oddly, if I refresh the ugly error page, I am correctly redirected to the login page.

      I have no idea why this line is throwing an error, but I'd like to wrap it in a try/catch block and have it return "green" in case of exception.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                darius Darius Jazayeri
                Reporter:
                darius Darius Jazayeri
                Designated Committer:
                Darius Jazayeri Darius Jazayeri
                Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:

                    Time Tracking

                    Estimated:
                    Original Estimate - 2 hours
                    2h
                    Remaining:
                    Remaining Estimate - 0 minutes
                    0m
                    Logged:
                    Time Spent - 2 hours
                    2h