[
https://issues.apache.org/jira/browse/WW-3444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12910355#action_12910355
]
Rene Gielen commented on WW-3444:
---------------------------------
The exception as thrown must be considered correct, since the portlet
dispatcher - basically a Portlet - is not in control of the response in the
render phase.
The question to ask is, what outcome would be expected from the JSON result in
this context? Due to the way the Portal works, the response of the Struts
action after action+render phase would be the JSON output embedded in the full
blown HTML portal page.
There are basically two ways to get a "naked" outcome, just containing the JSON
payload:
- within JSR168 (Portlet 1.0) - which is the specification version the current
stable S2 portlet plugin supports; one would need to access the action via the
Servlet side of the deployed portlet app - a portlet app is always also a
Servlet app, deployed under it's own context
- within JSR286 (Portlet 2.0), the serveResource call was introduced to address
this problem. The new S2 portlet plugin, still in sandbox
(https://svn.apache.org/repos/asf/struts/sandbox/trunk/struts2-portlet2-plugin/)
supports serveResource. Although it does not support portlet events so far, it
is worth a check. Hopefully I'm soon be able to invest further time in S2P2
plugin...
> 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
>
> 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.
-
You can reply to this email to add a comment to the issue online.