Foren
ClassCastException while overriding struts action
Hubert Dabrowski, geändert vor 12 Jahren.
ClassCastException while overriding struts action
New Member Beiträge: 2 Beitrittsdatum: 16.04.12 Neueste Beiträge
Hello,
I'm trying to override struts actions EditConfigurationAction and UpdateLayoutAction but Liferay throws an exception while opening any portlet configuration or adding a portlet to page. Other actions like EditTemplateAction are working correctly.
I've tried this on both 6.1.0 and 6.1.0 GA1.
Action:
Exception:
Action:
Exception:
I was unable to find a reason why this doesn't work so could someone tell me whether I'm doing anything wrong or is it a Liferay bug?
Regards
Hubert
I'm trying to override struts actions EditConfigurationAction and UpdateLayoutAction but Liferay throws an exception while opening any portlet configuration or adding a portlet to page. Other actions like EditTemplateAction are working correctly.
I've tried this on both 6.1.0 and 6.1.0 GA1.
<!--?xml version="1.0"?-->
<hook>
<portal-properties>portal.properties</portal-properties>
<language-properties>content/Language.properties</language-properties>
<language-properties>content/Language_en.properties</language-properties>
<language-properties>content/Language_pl.properties</language-properties>
<struts-action>
<struts-action-path>/portlet_configuration/edit_configuration</struts-action-path>
<struts-action-impl>pl.eo.liferay.audit.action.EditConfigurationActionHook</struts-action-impl>
</struts-action>
<struts-action>
<struts-action-path>/portal/update_layout</struts-action-path>
<struts-action-impl>pl.eo.liferay.audit.action.UpdateLayoutActionHook</struts-action-impl>
</struts-action>
</hook>
Action:
public class EditConfigurationActionHook extends BaseStrutsAction {
@Override
public String execute(StrutsAction originalStrutsAction,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
return originalStrutsAction.execute(originalStrutsAction, request, response);
}
Exception:
ERROR [render_portlet_jsp:154] java.lang.ClassCastException: com.liferay.portal.struts.ActionAdapter cannot be cast to com.liferay.portal.struts.PortletActionAdapter
at com.liferay.portal.struts.PortletRequestProcessor.processActionCreate(PortletRequestProcessor.java:304)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:230)
at com.liferay.portal.struts.PortletRequestProcessor.process(PortletRequestProcessor.java:230)
at com.liferay.portlet.StrutsPortlet.include(StrutsPortlet.java:239)
at com.liferay.portlet.StrutsPortlet.doView(StrutsPortlet.java:152)
at com.liferay.portal.kernel.portlet.LiferayPortlet.doDispatch(LiferayPortlet.java:211)
at javax.portlet.GenericPortlet.render(GenericPortlet.java:233)
at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:100)
at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:64)
at com.liferay.portlet.InvokerPortletImpl.invoke(InvokerPortletImpl.java:651)
at com.liferay.portlet.InvokerPortletImpl.invokeRender(InvokerPortletImpl.java:722)
at com.liferay.portlet.InvokerPortletImpl.render(InvokerPortletImpl.java:426)
at org.apache.jsp.html.portal.render_005fportlet_jsp._jspService(render_005fportlet_jsp.java:1215)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
Action:
public class UpdateLayoutActionHook extends BaseStrutsPortletAction {
@Override
public void processAction(StrutsPortletAction originalStrutsPortletAction,
PortletConfig portletConfig, ActionRequest actionRequest,
ActionResponse actionResponse) throws Exception {
originalStrutsPortletAction.processAction(originalStrutsPortletAction, portletConfig, actionRequest, actionResponse);
}
}
Exception:
ERROR [StripFilter:59] java.lang.ClassCastException: com.liferay.portal.struts.PortletActionAdapter cannot be cast to com.liferay.portal.struts.ActionAdapter
java.lang.ClassCastException: com.liferay.portal.struts.PortletActionAdapter cannot be cast to com.liferay.portal.struts.ActionAdapter
at com.liferay.portal.struts.PortalRequestProcessor.processActionCreate(PortalRequestProcessor.java:485)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:230)
at com.liferay.portal.struts.PortalRequestProcessor.process(PortalRequestProcessor.java:174)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at com.liferay.portal.servlet.MainServlet.callParentService(MainServlet.java:533)
at com.liferay.portal.servlet.MainServlet.service(MainServlet.java:510)
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 com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:121)
at com.liferay.portal.servlet.filters.strip.StripFilter.processFilter(StripFilter.java:304)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:203)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:105)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:113)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:121)
at com.liferay.portal.servlet.filters.gzip.GZipFilter.processFilter(GZipFilter.java:123)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:203)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:105)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:121)
at com.liferay.portal.servlet.filters.secure.SecureFilter.processFilter(SecureFilter.java:201)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:203)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:105)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:121)
at com.liferay.portal.servlet.filters.sso.ntlm.NtlmPostFilter.processFilter(NtlmPostFilter.java:83)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:203)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:105)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:121)
at com.liferay.portal.sharepoint.SharepointFilter.processFilter(SharepointFilter.java:80)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:203)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:105)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:121)
at com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter.processFilter(VirtualHostFilter.java:209)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:203)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:105)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:184)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:92)
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:738)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:203)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:105)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:164)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:92)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:164)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:92)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:184)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:92)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:70)
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:928)
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:539)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:300)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
I was unable to find a reason why this doesn't work so could someone tell me whether I'm doing anything wrong or is it a Liferay bug?
Regards
Hubert
David H Nebinger, geändert vor 12 Jahren.
RE: ClassCastException while overriding struts action
Liferay Legend Beiträge: 14915 Beitrittsdatum: 02.09.06 Neueste Beiträge
Class cast exceptions for the same class are always class loader issues.
You didn't mention how you were deploying this; I'm guessing a hook, which won't work because it's in a different class loader than the portal.
You didn't mention how you were deploying this; I'm guessing a hook, which won't work because it's in a different class loader than the portal.
Hubert Dabrowski, geändert vor 12 Jahren.
RE: ClassCastException while overriding struts action
New Member Beiträge: 2 Beitrittsdatum: 16.04.12 Neueste Beiträge
Does this mean there is currently no way to use a hook to override a struts action that is a part of the portal and not one of its portlets?
I'm asking because there is no information about such limitation and I've successfully overriden actions from portlets that are bundled with Liferay.
I'm asking because there is no information about such limitation and I've successfully overriden actions from portlets that are bundled with Liferay.
David H Nebinger, geändert vor 12 Jahren.
RE: ClassCastException while overriding struts action
Liferay Legend Beiträge: 14915 Beitrittsdatum: 02.09.06 Neueste Beiträge
That's pretty much it. I know folks have tried overriding struts actions via a hook, you might try searching the forums for a possible solution.
The easiest method is to do this via an EXT plugin, since you don't have to worry about the class loader issues at that point. And hey, that's what the ext plugin is for...
The easiest method is to do this via an EXT plugin, since you don't have to worry about the class loader issues at that point. And hey, that's what the ext plugin is for...
Ondřej Životský, geändert vor 11 Jahren.
RE: ClassCastException while overriding struts action (Antwort)
Junior Member Beiträge: 29 Beitrittsdatum: 11.03.11 Neueste Beiträge
I got the same problem today, so for everyone who has this problem...
1) first Exception - ActionAdapter cannot be cast to PortletActionAdapter - means you implemneted BaseStrutsAction instead of BaseStrutsPortletAction
2) second Exception - PortletActionAdapter cannot be cast to ActionAdapter - means you implemneted BaseStrutsPortletAction instead of BaseStrutsAction
I hope it helps someone
Ondrej
1) first Exception - ActionAdapter cannot be cast to PortletActionAdapter - means you implemneted BaseStrutsAction instead of BaseStrutsPortletAction
2) second Exception - PortletActionAdapter cannot be cast to ActionAdapter - means you implemneted BaseStrutsPortletAction instead of BaseStrutsAction
I hope it helps someone
Ondrej
Angelos Varvitsiotis, geändert vor 11 Jahren.
RE: ClassCastException while overriding struts action
New Member Beiträge: 6 Beitrittsdatum: 26.07.11 Neueste Beiträge
You sure did help me! I was trying to add a configuration tab by hook'ing the portlet_configuration portlet. Extending BaseStrutsPortletAction and returning the right forward did the trick. Thanks!