Details

      Description

      Portlets always throw the following exception:

      java.lang.IllegalStateException: Not allowed in a portlet

      Below is the method in the classs
      org.apache.struts2.portlet.servlet.PortletServletRequest where this always
      happens:

      public Cookie[] getCookies() {
          if (portletRequest instanceof HttpServletRequest) {
              return ((HttpServletRequest) portletRequest).getCookies();
          }
          throw new IllegalStateException("Not allowed in a portlet");
      }
      

      Apparently, the "portletRequest" variable is not an instance of "HttpServletRequest".

      NOTE - There are many other methods in class PortletServletRequest that use the exact same assumption/logic as the "getCookies()" method.

      That class is invoked by the class
      org.apache.struts2.interceptor.I18nInterceptor, which was just changed in version 2.5.5. See change https://issues.apache.org/jira/browse/WW-4686

      Finally, below is a partial stack trace

      SEVERE: Servlet.service() for servlet struts2portlet threw exception
      java.lang.IllegalStateException: Not allowed in a portlet
      at
      org.apache.struts2.portlet.servlet.PortletServletRequest.getCookies(PortletServletRequest.java:101)
      at
      org.apache.struts2.interceptor.I18nInterceptor.readStoredLocale(I18nInterceptor.java:215)
      at
      org.apache.struts2.interceptor.I18nInterceptor.storeLocale(I18nInterceptor.java:189)
      at
      org.apache.struts2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:144)
      at
      com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:240)
      at
      org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:171)
      at
      com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:240)
      at
      com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:195)
      at
      com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:240)
      at
      com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:193)
      at
      com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:240)
      at
      org.apache.struts2.portlet.interceptor.PortletAwareInterceptor.intercept(PortletAwareInterceptor.java:81)
      at
      com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:240)
      at
      org.apache.struts2.portlet.interceptor.PortletStateInterceptor.intercept(PortletStateInterceptor.java:51)
      at
      com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:240)
      at
      org.apache.struts2.factory.StrutsActionProxy.execute(StrutsActionProxy.java:54)
      at
      org.apache.struts2.portlet.dispatcher.Jsr168Dispatcher.serviceAction(Jsr168Dispatcher.java:481)
      at
      org.apache.struts2.portlet.dispatcher.Jsr168Dispatcher.render(Jsr168Dispatcher.java:341)
      at
      org.jasig.portal.portlet.container.FilterChainImpl.doFilter(FilterChainImpl.java:183)
      at
      org.jasig.portal.portlet.container.FilterChainImpl.processFilter(FilterChainImpl.java:99)
      at
      org.jasig.portal.portlet.container.FilterManagerImpl.processFilter(FilterManagerImpl.java:110)
      at
      org.apache.pluto.container.driver.PortletServlet.dispatch(PortletServlet.java:340)
      at
      org.apache.pluto.container.driver.PortletServlet.doGet(PortletServlet.java:261)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

        Issue Links

          Activity

          Hide
          hudson Hudson added a comment -

          UNSTABLE: Integrated in Jenkins build Struts-JDK7-master #583 (See https://builds.apache.org/job/Struts-JDK7-master/583/)
          WW-4722 Uses proper read method (lukaszlenart: rev d12bb7cddbc8f3ebbba64d3df209bb078735e8ea)

          • (edit) core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java
          Show
          hudson Hudson added a comment - UNSTABLE: Integrated in Jenkins build Struts-JDK7-master #583 (See https://builds.apache.org/job/Struts-JDK7-master/583/ ) WW-4722 Uses proper read method (lukaszlenart: rev d12bb7cddbc8f3ebbba64d3df209bb078735e8ea) (edit) core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java
          Hide
          lukaszlenart Lukasz Lenart added a comment -

          woops, thanks

          Show
          lukaszlenart Lukasz Lenart added a comment - woops, thanks
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit d12bb7cddbc8f3ebbba64d3df209bb078735e8ea in struts's branch refs/heads/master from Lukasz Lenart
          [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=d12bb7c ]

          WW-4722 Uses proper read method

          Show
          jira-bot ASF subversion and git services added a comment - Commit d12bb7cddbc8f3ebbba64d3df209bb078735e8ea in struts's branch refs/heads/master from Lukasz Lenart [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=d12bb7c ] WW-4722 Uses proper read method
          Hide
          igor.schuraev Igor Schuraev added a comment -

          The change in commit baffa9a68b2ff02cab3387ab0b53794a1e541c7e seems to be not correct.
          if storage is COOKIE, then read from session. If storage is session, then read from cookies.
          if (storage == Storage.COOKIE) {
          locale = readStoredLocalFromSession(invocation);
          if (storage == Storage.SESSION) {
          locale = readStoredLocaleFromCookie(invocation);

          Show
          igor.schuraev Igor Schuraev added a comment - The change in commit baffa9a68b2ff02cab3387ab0b53794a1e541c7e seems to be not correct. if storage is COOKIE, then read from session. If storage is session, then read from cookies. if (storage == Storage.COOKIE) { locale = readStoredLocalFromSession(invocation); if (storage == Storage.SESSION) { locale = readStoredLocaleFromCookie(invocation);
          Hide
          hudson Hudson added a comment -

          SUCCESS: Integrated in Jenkins build Struts-JDK7-master #570 (See https://builds.apache.org/job/Struts-JDK7-master/570/)
          WW-4722 Checks proper scope for stored locale (lukaszlenart: rev baffa9a68b2ff02cab3387ab0b53794a1e541c7e)

          • (edit) core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java
          Show
          hudson Hudson added a comment - SUCCESS: Integrated in Jenkins build Struts-JDK7-master #570 (See https://builds.apache.org/job/Struts-JDK7-master/570/ ) WW-4722 Checks proper scope for stored locale (lukaszlenart: rev baffa9a68b2ff02cab3387ab0b53794a1e541c7e) (edit) core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit baffa9a68b2ff02cab3387ab0b53794a1e541c7e in struts's branch refs/heads/master from Lukasz Lenart
          [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=baffa9a ]

          WW-4722 Checks proper scope for stored locale

          Show
          jira-bot ASF subversion and git services added a comment - Commit baffa9a68b2ff02cab3387ab0b53794a1e541c7e in struts's branch refs/heads/master from Lukasz Lenart [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=baffa9a ] WW-4722 Checks proper scope for stored locale
          Hide
          hudson Hudson added a comment -

          SUCCESS: Integrated in Jenkins build Struts-JDK7-master #567 (See https://builds.apache.org/job/Struts-JDK7-master/567/)
          WW-4722 Renames constant for better readability (lukaszlenart: rev bcea4c9bafb101901543c97174fb3d20d0f0c017)

          • (edit) core/src/test/java/org/apache/struts2/interceptor/I18nInterceptorTest.java
          • (edit) core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java
            WW-4722 Allows predefine default store location (lukaszlenart: rev 6e1ea61dc664c4a4e41a8a094030f2edf0088f6c)
          • (edit) core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java
            WW-4722 Refactors code to use predefined storage locatio (lukaszlenart: rev 6457f002d97cde76f98444ec98abdb9bc4be191f)
          • (edit) core/src/test/java/org/apache/struts2/interceptor/I18nInterceptorTest.java
          • (edit) core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java
            WW-4722 Extracts logic to store locale in cookie into a method (lukaszlenart: rev 8971b5081055bd309f715aad63fd96825154c3f8)
          • (edit) core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java
            WW-4722 Reuses global fields and cleans up logging (lukaszlenart: rev fddc6582e0a66e82b045824fb214e43d7d6c36fd)
          • (edit) core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java
            WW-4722 Prepares ActionProxy to be used with test (lukaszlenart: rev f515def5b82f29b2accac056e2148077047bdfd1)
          • (edit) core/src/test/java/org/apache/struts2/interceptor/I18nInterceptorTest.java
            WW-4722 Refactors store logic (lukaszlenart: rev aabc90df6b8293f597903ac2c9016270b4a37d52)
          • (edit) core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java
            WW-4722 Adds description of storage parameter (lukaszlenart: rev 09958919caabc66d3b963b81af6f8c3c4b44efe0)
          • (edit) core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java
          Show
          hudson Hudson added a comment - SUCCESS: Integrated in Jenkins build Struts-JDK7-master #567 (See https://builds.apache.org/job/Struts-JDK7-master/567/ ) WW-4722 Renames constant for better readability (lukaszlenart: rev bcea4c9bafb101901543c97174fb3d20d0f0c017) (edit) core/src/test/java/org/apache/struts2/interceptor/I18nInterceptorTest.java (edit) core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java WW-4722 Allows predefine default store location (lukaszlenart: rev 6e1ea61dc664c4a4e41a8a094030f2edf0088f6c) (edit) core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java WW-4722 Refactors code to use predefined storage locatio (lukaszlenart: rev 6457f002d97cde76f98444ec98abdb9bc4be191f) (edit) core/src/test/java/org/apache/struts2/interceptor/I18nInterceptorTest.java (edit) core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java WW-4722 Extracts logic to store locale in cookie into a method (lukaszlenart: rev 8971b5081055bd309f715aad63fd96825154c3f8) (edit) core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java WW-4722 Reuses global fields and cleans up logging (lukaszlenart: rev fddc6582e0a66e82b045824fb214e43d7d6c36fd) (edit) core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java WW-4722 Prepares ActionProxy to be used with test (lukaszlenart: rev f515def5b82f29b2accac056e2148077047bdfd1) (edit) core/src/test/java/org/apache/struts2/interceptor/I18nInterceptorTest.java WW-4722 Refactors store logic (lukaszlenart: rev aabc90df6b8293f597903ac2c9016270b4a37d52) (edit) core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java WW-4722 Adds description of storage parameter (lukaszlenart: rev 09958919caabc66d3b963b81af6f8c3c4b44efe0) (edit) core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 09958919caabc66d3b963b81af6f8c3c4b44efe0 in struts's branch refs/heads/master from Lukasz Lenart
          [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=0995891 ]

          WW-4722 Adds description of storage parameter

          Show
          jira-bot ASF subversion and git services added a comment - Commit 09958919caabc66d3b963b81af6f8c3c4b44efe0 in struts's branch refs/heads/master from Lukasz Lenart [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=0995891 ] WW-4722 Adds description of storage parameter
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit aabc90df6b8293f597903ac2c9016270b4a37d52 in struts's branch refs/heads/master from Lukasz Lenart
          [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=aabc90d ]

          WW-4722 Refactors store logic

          Show
          jira-bot ASF subversion and git services added a comment - Commit aabc90df6b8293f597903ac2c9016270b4a37d52 in struts's branch refs/heads/master from Lukasz Lenart [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=aabc90d ] WW-4722 Refactors store logic
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit f515def5b82f29b2accac056e2148077047bdfd1 in struts's branch refs/heads/master from Lukasz Lenart
          [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=f515def ]

          WW-4722 Prepares ActionProxy to be used with test

          Show
          jira-bot ASF subversion and git services added a comment - Commit f515def5b82f29b2accac056e2148077047bdfd1 in struts's branch refs/heads/master from Lukasz Lenart [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=f515def ] WW-4722 Prepares ActionProxy to be used with test
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit fddc6582e0a66e82b045824fb214e43d7d6c36fd in struts's branch refs/heads/master from Lukasz Lenart
          [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=fddc658 ]

          WW-4722 Reuses global fields and cleans up logging

          Show
          jira-bot ASF subversion and git services added a comment - Commit fddc6582e0a66e82b045824fb214e43d7d6c36fd in struts's branch refs/heads/master from Lukasz Lenart [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=fddc658 ] WW-4722 Reuses global fields and cleans up logging
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 8971b5081055bd309f715aad63fd96825154c3f8 in struts's branch refs/heads/master from Lukasz Lenart
          [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=8971b50 ]

          WW-4722 Extracts logic to store locale in cookie into a method

          Show
          jira-bot ASF subversion and git services added a comment - Commit 8971b5081055bd309f715aad63fd96825154c3f8 in struts's branch refs/heads/master from Lukasz Lenart [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=8971b50 ] WW-4722 Extracts logic to store locale in cookie into a method
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 6457f002d97cde76f98444ec98abdb9bc4be191f in struts's branch refs/heads/master from Lukasz Lenart
          [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=6457f00 ]

          WW-4722 Refactors code to use predefined storage locatio

          Show
          jira-bot ASF subversion and git services added a comment - Commit 6457f002d97cde76f98444ec98abdb9bc4be191f in struts's branch refs/heads/master from Lukasz Lenart [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=6457f00 ] WW-4722 Refactors code to use predefined storage locatio
          Hide
          lukaszlenart Lukasz Lenart added a comment -

          Resolved, thanks for reporting!

          Show
          lukaszlenart Lukasz Lenart added a comment - Resolved, thanks for reporting!
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 6e1ea61dc664c4a4e41a8a094030f2edf0088f6c in struts's branch refs/heads/master from Lukasz Lenart
          [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=6e1ea61 ]

          WW-4722 Allows predefine default store location

          Show
          jira-bot ASF subversion and git services added a comment - Commit 6e1ea61dc664c4a4e41a8a094030f2edf0088f6c in struts's branch refs/heads/master from Lukasz Lenart [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=6e1ea61 ] WW-4722 Allows predefine default store location
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit bcea4c9bafb101901543c97174fb3d20d0f0c017 in struts's branch refs/heads/master from Lukasz Lenart
          [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=bcea4c9 ]

          WW-4722 Renames constant for better readability

          Show
          jira-bot ASF subversion and git services added a comment - Commit bcea4c9bafb101901543c97174fb3d20d0f0c017 in struts's branch refs/heads/master from Lukasz Lenart [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=bcea4c9 ] WW-4722 Renames constant for better readability

            People

            • Assignee:
              lukaszlenart Lukasz Lenart
              Reporter:
              tkofford Todd Kofford
            • Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development