Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-65930

ClassCastException when using RenderResponseWrapper in portlet filter

    Details

      Description

      Steps to reproduce:

      • create a bundle with PortletFilter component
      • provide property javax.portlet.name=com_liferay_asset_publisher_web_portlet_AssetPublisherPortlet for the component to apply filter to AssetPublisher portlet
      • inside PortletFilter use an instance of RenderResponseWrapper to replace the original response object
      • deploy the bundle and go to any page that contains AssetPublisher portlet

      Expected result: the portlet displays content properly
      Actual result: portlet does not display content due to ClassCastException like this:

      8:24:39,653 ERROR [http-nio-8080-exec-7][AssetPublisherPortletToolbarContributor:236] Unable to add folder menu item
      java.lang.ClassCastException: com.liferay.blade.samples.portlet.filter.WrapperPortletRender cannot be cast to com.liferay.portal.kernel.portlet.LiferayPortletResponse
      	at com.liferay.asset.publisher.web.portlet.toolbar.contributor.AssetPublisherPortletToolbarContributor._getScopeAddPortletURLs(AssetPublisherPortletToolbarContributor.java:318)
      	at com.liferay.asset.publisher.web.portlet.toolbar.contributor.AssetPublisherPortletToolbarContributor.addPortletTitleAddAssetEntryMenuItems(AssetPublisherPortletToolbarContributor.java:124)
      	at com.liferay.asset.publisher.web.portlet.toolbar.contributor.AssetPublisherPortletToolbarContributor.getPortletTitleMenuItems(AssetPublisherPortletToolbarContributor.java:232)
      	at com.liferay.asset.publisher.web.portlet.toolbar.contributor.AssetPublisherPortletToolbarContributor.getAddEntryPortletTitleMenu(AssetPublisherPortletToolbarContributor.java:199)
      	at com.liferay.asset.publisher.web.portlet.toolbar.contributor.AssetPublisherPortletToolbarContributor.getPortletTitleMenus(AssetPublisherPortletToolbarContributor.java:81)
      	at com.liferay.portal.kernel.portlet.toolbar.PortletToolbar.getPortletTitleMenus(PortletToolbar.java:82)
      	at sun.reflect.GeneratedMethodAccessor991.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at freemarker.ext.beans.BeansWrapper.invokeMethod(BeansWrapper.java:1458)
      	at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:71)
      	at freemarker.core.MethodCall._eval(MethodCall.java:62)
      	at freemarker.core.Expression.eval(Expression.java:78)
      	at freemarker.core.Assignment.accept(Assignment.java:131)
      	at freemarker.core.Environment.visit(Environment.java:324)
      	at freemarker.core.MixedContent.accept(MixedContent.java:54)
      	at freemarker.core.Environment.visitByHiddingParent(Environment.java:345)
      	at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:48)
      	at freemarker.core.Environment.visit(Environment.java:324)
      	at freemarker.core.MixedContent.accept(MixedContent.java:54)
      	at freemarker.core.Environment.visit(Environment.java:324)
      	at freemarker.core.Environment.process(Environment.java:302)
      	at freemarker.template.Template.process(Template.java:325)
      	at com.liferay.portal.template.freemarker.FreeMarkerTemplate.processTemplate(FreeMarkerTemplate.java:121)
      ....
      

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                2 years, 2 weeks, 3 days ago

                Packages

                Version Package
                7.0.0 DXP FP21
                7.0.0 DXP SP4
                7.0.X EE
                7.1.X
                Master