Uploaded image for project: 'Reference Application'
  1. Reference Application
  2. RA-899

StringIndexOutOfBoundsException When Browsing to OpenMRS 2 From Another Site

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • TBD
    • Resolution: Won't Fix
    • OpenMRS 2.2
    • None
    • None
    • Undetermined

    Description

      When I attempt to browse to the OpenMRS Demo site via a link on another web site, I get the exception below. The browser appears to get redirected to the /login.htm page, as it should be, from which the exception is thrown. If I simply browse to the same login.htm url from a new browser window/tab the login page renders properly as does clicking on the 'Log In' link even after the exception occurs. However, refreshing the exception page still results in the exception.

      I noticed this issue when trying to create a link from our OpenHMIS site to an OpenMRS 2 demo site. You can reproduce this by:

      1. Going to http://www.openhmis.org
      2. Hover over the Technical menu
      3. Click on the OpenHMIS Demo Site menu item
      4. Instead of being directed to the login page, the exception below will be thrown.

      I have tested this with our OpenMRS 2 demo site (http://demo2.openhmisafrica.org) as well as the main OpenMRS demo site (http://demo.openmrs.org) with the same results.

      Exception Details:

      UI Framework Error
      Root Error
      java.lang.StringIndexOutOfBoundsException: String index out of range: -1
      	at java.lang.String.substring(String.java:1911)
      	at org.openmrs.module.referenceapplication.page.controller.LoginPageController.getRedirectUrlFromReferer(LoginPageController.java:126)
      	at org.openmrs.module.referenceapplication.page.controller.LoginPageController.get(LoginPageController.java:91)
      	at sun.reflect.GeneratedMethodAccessor1076.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      	at org.openmrs.ui.framework.UiFrameworkUtil.invokeMethodWithArguments(UiFrameworkUtil.java:105)
      	at org.openmrs.ui.framework.UiFrameworkUtil.executeControllerMethod(UiFrameworkUtil.java:64)
      	at org.openmrs.ui.framework.page.PageFactory.handleRequestWithController(PageFactory.java:216)
      	at org.openmrs.ui.framework.page.PageFactory.processThisFragment(PageFactory.java:158)
      	at org.openmrs.ui.framework.page.PageFactory.process(PageFactory.java:114)
      	at org.openmrs.ui.framework.page.PageFactory.handle(PageFactory.java:84)
      	at org.openmrs.module.uiframework.PageController.handlePath(PageController.java:110)
      	at org.openmrs.module.uiframework.PageController.handleUrlWithDotPage(PageController.java:77)
      	at sun.reflect.GeneratedMethodAccessor980.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      	at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
      	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:440)
      	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:428)
      	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
      	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
      	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953)
      	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:844)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
      	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
      	at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471)
      	at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
      	at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
      	at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
      	at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:263)
      	at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1208)
      	at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:992)
      	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:939)
      	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
      	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953)
      	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:844)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
      	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.openmrs.module.web.filter.ForcePasswordChangeFilter.doFilter(ForcePasswordChangeFilter.java:61)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.openmrs.web.filter.GZIPFilter.doFilterInternal(GZIPFilter.java:64)
      	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:72)
      	at org.openmrs.module.web.filter.ModuleFilter.doFilter(ModuleFilter.java:54)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.openmrs.web.filter.OpenmrsFilter.doFilterInternal(OpenmrsFilter.java:109)
      	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:230)
      	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:105)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:105)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:105)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
      	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
      	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
      	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
      	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
      	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
      	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
      	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
      	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
      	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
      	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
      	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      	at java.lang.Thread.run(Thread.java:745)
      Full Error
      java.lang.StringIndexOutOfBoundsException: String index out of range: -1
      	at java.lang.String.substring(String.java:1911)
      	at org.openmrs.module.referenceapplication.page.controller.LoginPageController.getRedirectUrlFromReferer(LoginPageController.java:126)
      	at org.openmrs.module.referenceapplication.page.controller.LoginPageController.get(LoginPageController.java:91)
      	at sun.reflect.GeneratedMethodAccessor1076.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      	at org.openmrs.ui.framework.UiFrameworkUtil.invokeMethodWithArguments(UiFrameworkUtil.java:105)
      	at org.openmrs.ui.framework.UiFrameworkUtil.executeControllerMethod(UiFrameworkUtil.java:64)
      	at org.openmrs.ui.framework.page.PageFactory.handleRequestWithController(PageFactory.java:216)
      	at org.openmrs.ui.framework.page.PageFactory.processThisFragment(PageFactory.java:158)
      	at org.openmrs.ui.framework.page.PageFactory.process(PageFactory.java:114)
      	at org.openmrs.ui.framework.page.PageFactory.handle(PageFactory.java:84)
      	at org.openmrs.module.uiframework.PageController.handlePath(PageController.java:110)
      	at org.openmrs.module.uiframework.PageController.handleUrlWithDotPage(PageController.java:77)
      	at sun.reflect.GeneratedMethodAccessor980.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      	at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
      	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:440)
      	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:428)
      	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
      	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
      	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953)
      	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:844)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
      	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
      	at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471)
      	at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
      	at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
      	at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
      	at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:263)
      	at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1208)
      	at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:992)
      	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:939)
      	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
      	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953)
      	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:844)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
      	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.openmrs.module.web.filter.ForcePasswordChangeFilter.doFilter(ForcePasswordChangeFilter.java:61)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.openmrs.web.filter.GZIPFilter.doFilterInternal(GZIPFilter.java:64)
      	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:72)
      	at org.openmrs.module.web.filter.ModuleFilter.doFilter(ModuleFilter.java:54)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.openmrs.web.filter.OpenmrsFilter.doFilterInternal(OpenmrsFilter.java:109)
      	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:230)
      	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:105)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:105)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:105)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
      	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
      	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
      	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
      	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
      	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
      	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
      	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
      	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
      	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
      	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
      	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      	at java.lang.Thread.run(Thread.java:745)

      Gliffy Diagrams

        Attachments

          Activity

            People

              Unassigned Unassigned
              ibewes Wesley Brown
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: