You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Johannes Geppert (JIRA)" <ji...@apache.org> on 2011/02/04 08:27:25 UTC

[jira] Updated: (WW-3444) JSON plugin thows java.lang.IllegalStateException when used together with Struts2 Portlet Bridge

     [ https://issues.apache.org/jira/browse/WW-3444?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Johannes Geppert updated WW-3444:
---------------------------------

    Attachment: testportlet.war

following war produced this error with portlet2 sandbox version.

1.) Install war
2.) Add "JSON Test Portlet"
3.) Click on the "Get JSON" Link

In the Stacktrace you can find following lines:

Caused by: javax.portlet.PortletException: Error executing action jsonlanguages
        at org.apache.struts2.portlet.dispatcher.Jsr168Dispatcher.serviceAction(Jsr168Dispatcher.java:442)
        at org.apache.struts2.portlet.dispatcher.Jsr286Dispatcher.serveResource(Jsr286Dispatcher.java:43)
        at com.ibm.ws.portletcontainer.invoker.impl.PortletServlet.doDispatch(PortletServlet.java:548)
        at com.ibm.ws.portletcontainer.invoker.impl.PortletServlet.doDispatch(PortletServlet.java:332)
        ... 103 more
Caused by: java.lang.IllegalStateException: Only allowed in resource phase
        at org.apache.struts2.portlet.servlet.PortletServletResponseJSR286.setContentLength(PortletServletResponseJSR286.java:133)
        at org.apache.struts2.json.JSONUtil.writeJSONToResponse(JSONUtil.java:253)
        at org.apache.struts2.json.JSONResult.writeToResponse(JSONResult.java:214)
        at org.apache.struts2.json.JSONResult.execute(JSONResult.java:204)


> JSON plugin thows java.lang.IllegalStateException when used together with Struts2 Portlet Bridge
> ------------------------------------------------------------------------------------------------
>
>                 Key: WW-3444
>                 URL: https://issues.apache.org/jira/browse/WW-3444
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - JSON
>    Affects Versions: 2.1.8.1
>         Environment: OS: Linux, Sun JDK 1.6.0.19, Liferay 5.2.3 running on Tomcat 6.0.26
>            Reporter: Per Pascal Grube
>            Assignee: Lukasz Lenart
>         Attachments: testportlet.war
>
>
> When trying to use the JSON Plugin when Struts is running as a portlet a java.lang.IllegalStateException: Not allowed in an a portlet is thrown.
> The full stacktrace is: 
> java.lang.IllegalStateException: Not allowed in a portlet
>         at org.apache.struts2.portlet.servlet.PortletServletResponse.setContentLength(PortletServletResponse.java:214)
>         at org.apache.struts2.json.JSONUtil.writeJSONToResponse(JSONUtil.java:253)
>         at org.apache.struts2.json.JSONResult.writeToResponse(JSONResult.java:214)
>         at org.apache.struts2.json.JSONResult.execute(JSONResult.java:204)
>         at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:362)
>         at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:266)
>         at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)
>         at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
>         at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
>         at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252)
>         at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
>         at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
> --cut...
> Surrounding line 260 [ response.setContentLength(json.getBytes(serializationParams.getEncoding()).length); ] in org/apache/struts2/json/JSONUtil.java makes it possible to get it running, but I guess it should be avoided at all to run into this exception.

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira