You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by tkofford <tk...@ku.edu> on 2016/11/30 22:30:29 UTC

Portlet Issue From Struts version 2.5 to 2.5.5?

We've been trying to upgrade from struts 2.5 to struts 2.5.5, and most of our
webapps are portlets. However, with struts 2.5.5 portlets throws 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".

That class is invoked by the class
org.apache.struts2.interceptor.I18nInterceptor, which I noticed was changed
from version 2.5 which used the old xwork package version of that class. I
also noticed that cookie handling was added in version 2.5.5.

Finally, below is a partial stack trace. Any help would be greatly
appreciated!

Thanks in advance!

Todd Kofford
University of Kansas - IT
tkofford@ku.edu

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)




--
View this message in context: http://struts.1045723.n5.nabble.com/Portlet-Issue-From-Struts-version-2-5-to-2-5-5-tp5720470.html
Sent from the Struts - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Portlet Issue From Struts version 2.5 to 2.5.5?

Posted by tkofford <tk...@ku.edu>.
Issue reported as
https://issues.apache.org/jira/browse/WW-4722
<https://issues.apache.org/jira/browse/WW-4722>  



--
View this message in context: http://struts.1045723.n5.nabble.com/Portlet-Issue-From-Struts-version-2-5-to-2-5-5-tp5720470p5720475.html
Sent from the Struts - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Portlet Issue From Struts version 2.5 to 2.5.5?

Posted by Lukasz Lenart <lu...@apache.org>.
It's related to this change
https://issues.apache.org/jira/browse/WW-4686

let me think how to resolve that and feel free to register a bug
linking to this issue


Regards
-- 
Ɓukasz
+ 48 606 323 122 http://www.lenart.org.pl/

2016-11-30 23:30 GMT+01:00 tkofford <tk...@ku.edu>:
> We've been trying to upgrade from struts 2.5 to struts 2.5.5, and most of our
> webapps are portlets. However, with struts 2.5.5 portlets throws 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".
>
> That class is invoked by the class
> org.apache.struts2.interceptor.I18nInterceptor, which I noticed was changed
> from version 2.5 which used the old xwork package version of that class. I
> also noticed that cookie handling was added in version 2.5.5.
>
> Finally, below is a partial stack trace. Any help would be greatly
> appreciated!
>
> Thanks in advance!
>
> Todd Kofford
> University of Kansas - IT
> tkofford@ku.edu
>
> 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)
>
>
>
>
> --
> View this message in context: http://struts.1045723.n5.nabble.com/Portlet-Issue-From-Struts-version-2-5-to-2-5-5-tp5720470.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org