ICEfaces
  1. ICEfaces
  2. ICE-10952

ClassCastException thrown by FileEntryUpload.afterPhase(PhaseEvent) with Servlet 3.x (Tomcat 8) and portlets

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 4.1
    • Fix Version/s: 4.1.1
    • Component/s: ACE-Components
    • Labels:
      None
    • Environment:
      Liferay Portal 7 / Tomcat 8
    • Assignee Priority:
      P1

      Description

      Steps to Reproduce:

      - Download and install [Liferay Portal 7.0.0-B7|http://sourceforge.net/projects/lportal/files/Liferay%20Portal/7.0.0%20B7/] (scheduled to be released this week -- B7 includes Tomcat 8 whereas B6 includes Tomcat 7)

      - Copy the icefaces4-portlet-4.0.0-SNAPSHOT.war attachment from ICE-10951 to the $LIFERAY_HOME/deploy folder

      - Add a new portal page named ICE4
          - Click on the "Menu" icon in the UPPER LEFT corner
          - Click on the "+" icon that has title "Add Page"
          - Type "ICE4" for the name and press enter/return

      - Add the ICEfaces4 portlet to a portal page
          - Click on the "+" icon in the UPPER RIGHT conrer
          - Click on "Applications" in the accordion menu
          - Click on "Sample"
          - Click the "Add" link to the right of "ICEfaces4"

      - Reload the ICE4 page

      - Attempt to upload a file and click Submit

      If the bug is fixed, then the file will upload properly.

      Otherwise, if the bug still exists, then this error message will be rendered above the portlet: "The server request has failed because there was a problem reading the multi-part request"

      In the debugger, I found that the try/catch block at line#151 of FileEntryUpload.afterPhase(PhaseEvent) was getting hit:
      {code}
                              FacesMessage ajaxResponse = FileEntryStatuses.PROBLEM_READING_MULTIPART.getFacesMessage(facesContext, (UIComponent)null, (FileInfo)null);
                              facesContext.addMessage((String)null, ajaxResponse);
                              if(facesContext.isProjectStage(ProjectStage.Development)) {
                                  log.log(Level.WARNING, "Problem reading multi-part form upload, likely due to a file upload being cut off from the client losing their network connection or closing their browser tab or window.", var30);
                              }
      And the exception in the debugger is:
      {noformat}
      java.lang.ClassCastException: com.liferay.faces.bridge.filter.liferay.internal.ResourceRequestBridgeLiferayImpl cannot be cast to javax.servlet.http.HttpServletRequest
      {noformat}

      It is my best guess that this is happening in Liferay 7 (but not Liferay 6.2) because Liferay 7 is bundled with Tomcat 8, and this section of code in FileEntryUpload.java is executing because Class.forName("javax.servlet.http.Part") returned a non-null value, indicating Servlet 3.x (Tomcat 8) instead of Servlet 2.5 (Tomcat 7).

        Activity

        Hide
        Mircea Toma added a comment -

        I am not able to download Liferay Portal 7.0.0-B7. When accessing the provided link the browser is redirected to https://sourceforge.net/projects/lportal/files/ .

        Show
        Mircea Toma added a comment - I am not able to download Liferay Portal 7.0.0-B7. When accessing the provided link the browser is redirected to https://sourceforge.net/projects/lportal/files/ .
        Hide
        Neil Griffin added a comment -

        Hi Mircea, 7.0.0-B7 is scheduled to be released this week. Hopefully you will see the link working by Friday. If not then early next week. Thanks, Neil

        Show
        Neil Griffin added a comment - Hi Mircea, 7.0.0-B7 is scheduled to be released this week. Hopefully you will see the link working by Friday. If not then early next week. Thanks, Neil
        Hide
        Mircea Toma added a comment - - edited

        The problem you're seeing in Tomcat 8 might be caused by the misconfiguration of the web.xml file. The file upload needs to have the servlet container run in Servlet 3.0 mode which is triggered by specifying the correct version and namespace:

        <web-app version="3.0"
                 xmlns="http://java.sun.com/xml/ns/javaee"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
        ......
        

        Also the FacesServlet will need to have the multipart configuration specified:

            <servlet>
                <servlet-name>Faces Servlet</servlet-name>
                <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
                <!-- Add the multi-part entry below to enable Servlet 3 servers to support ace:fileEntry -->
                <multipart-config>
                    <max-file-size>52428800</max-file-size>
                    <max-request-size>52428800</max-request-size>
                    <file-size-threshold>0</file-size-threshold>
                </multipart-config>
            </servlet>
        

        Hopefully this will help.

        Show
        Mircea Toma added a comment - - edited The problem you're seeing in Tomcat 8 might be caused by the misconfiguration of the web.xml file. The file upload needs to have the servlet container run in Servlet 3.0 mode which is triggered by specifying the correct version and namespace: <web-app version= "3.0" xmlns= "http: //java.sun.com/xml/ns/javaee" xmlns:xsi= "http: //www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation= "http: //java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" > ...... Also the FacesServlet will need to have the multipart configuration specified: <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <!-- Add the multi-part entry below to enable Servlet 3 servers to support ace:fileEntry --> <multipart-config> <max-file-size>52428800</max-file-size> <max-request-size>52428800</max-request-size> <file-size-threshold>0</file-size-threshold> </multipart-config> </servlet> Hopefully this will help.
        Hide
        Neil Griffin added a comment -

        The icefaces4-portlet-4.0.0-SNAPSHOT.war attachment from ICE-10951 already had <web-app version="3.0" ... etc ... >

        However it did not have the <multipart-config> on the FacesServlet.

        When I added the <multipart-config> and re-deployed, I got a new exception:

        Cannot add the same component twice: _1_WAR_icefaces4portlet_INSTANCE_JRmpyc6WyFKT_:javascript_runner

        Show
        Neil Griffin added a comment - The icefaces4-portlet-4.0.0-SNAPSHOT.war attachment from ICE-10951 already had <web-app version="3.0" ... etc ... > However it did not have the <multipart-config> on the FacesServlet. When I added the <multipart-config> and re-deployed, I got a new exception: Cannot add the same component twice: _1_WAR_icefaces4portlet_INSTANCE_JRmpyc6WyFKT_:javascript_runner
        Hide
        Neil Griffin added a comment -

        FYI, Liferay Portal 7.0.0-B7 has been released.

        Show
        Neil Griffin added a comment - FYI, Liferay Portal 7.0.0-B7 has been released.
        Hide
        Neil Griffin added a comment -

        I just noticed that Liferay Portal 7.0.0-B7 was released with Tomcat 7 rather than Tomcat 8. I'll look into this and report back.

        Show
        Neil Griffin added a comment - I just noticed that Liferay Portal 7.0.0-B7 was released with Tomcat 7 rather than Tomcat 8. I'll look into this and report back.
        Hide
        Neil Griffin added a comment -

        I confirmed that it was indeed released with Tomcat 8. Please give it a try when you can. Thanks.

        Show
        Neil Griffin added a comment - I confirmed that it was indeed released with Tomcat 8. Please give it a try when you can. Thanks.
        Hide
        Mircea Toma added a comment -

        I cannot run icefaces4-portlet-4.0.0-SNAPSHOT.war on Liferay Portal 7.0.0-B7. I get this exception:

        13:11:45,699 ERROR [http-nio-8080-exec-19][render_portlet_jsp:131] null
        java.lang.NoClassDefFoundError: com/liferay/portal/theme/ThemeDisplay
        	at com.liferay.faces.bridge.context.liferay.internal.BridgePortalContextLiferayCompatImpl.isLiferayNamespacingParameters(BridgePortalContextLiferayCompatImpl.java:47)
        	at com.liferay.faces.bridge.context.liferay.internal.BridgePortalContextLiferayImpl.<init>(BridgePortalContextLiferayImpl.java:91)
        	at com.liferay.faces.bridge.filter.liferay.internal.BridgePortletRequestFactoryLiferayImpl.getRenderRequest(BridgePortletRequestFactoryLiferayImpl.java:73)
        	at com.liferay.faces.bridge.internal.BridgePhaseRenderImpl.<init>(BridgePhaseRenderImpl.java:75)
        	at com.liferay.faces.bridge.internal.BridgePhaseFactoryImpl.getBridgeRenderPhase(BridgePhaseFactoryImpl.java:54)
        	at com.liferay.faces.bridge.internal.BridgeImpl.doFacesRequest(BridgeImpl.java:129)
        	at javax.portlet.faces.GenericFacesPortlet.doView(GenericFacesPortlet.java:263)
        	at javax.portlet.GenericPortlet.doDispatch(GenericPortlet.java:359)
        	at javax.portlet.faces.GenericFacesPortlet.doDispatch(GenericFacesPortlet.java:212)
        	at javax.portlet.GenericPortlet.render(GenericPortlet.java:262)
        	at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:103)
        	at com.liferay.portlet.ScriptDataPortletFilter.doFilter(ScriptDataPortletFilter.java:57)
        	at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:100)
        	at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:64)
        	at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:113)
        	at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:119)
        	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:115)
        
        Show
        Mircea Toma added a comment - I cannot run icefaces4-portlet-4.0.0-SNAPSHOT.war on Liferay Portal 7.0.0-B7. I get this exception: 13:11:45,699 ERROR [http-nio-8080-exec-19][render_portlet_jsp:131] null java.lang.NoClassDefFoundError: com/liferay/portal/theme/ThemeDisplay at com.liferay.faces.bridge.context.liferay.internal.BridgePortalContextLiferayCompatImpl.isLiferayNamespacingParameters(BridgePortalContextLiferayCompatImpl.java:47) at com.liferay.faces.bridge.context.liferay.internal.BridgePortalContextLiferayImpl.<init>(BridgePortalContextLiferayImpl.java:91) at com.liferay.faces.bridge.filter.liferay.internal.BridgePortletRequestFactoryLiferayImpl.getRenderRequest(BridgePortletRequestFactoryLiferayImpl.java:73) at com.liferay.faces.bridge.internal.BridgePhaseRenderImpl.<init>(BridgePhaseRenderImpl.java:75) at com.liferay.faces.bridge.internal.BridgePhaseFactoryImpl.getBridgeRenderPhase(BridgePhaseFactoryImpl.java:54) at com.liferay.faces.bridge.internal.BridgeImpl.doFacesRequest(BridgeImpl.java:129) at javax.portlet.faces.GenericFacesPortlet.doView(GenericFacesPortlet.java:263) at javax.portlet.GenericPortlet.doDispatch(GenericPortlet.java:359) at javax.portlet.faces.GenericFacesPortlet.doDispatch(GenericFacesPortlet.java:212) at javax.portlet.GenericPortlet.render(GenericPortlet.java:262) at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:103) at com.liferay.portlet.ScriptDataPortletFilter.doFilter(ScriptDataPortletFilter.java:57) at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:100) at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:64) at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:113) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:119) at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:115)
        Hide
        Neil Griffin added a comment -

        Attached is an updated version of icefaces4-portlet-4.0.0-SNAPSHOT.war that contains the <multipart-config> in web.xml and the correct liferay-faces-bridge-ext.jar for Liferay 7.

        Show
        Neil Griffin added a comment - Attached is an updated version of icefaces4-portlet-4.0.0-SNAPSHOT.war that contains the <multipart-config> in web.xml and the correct liferay-faces-bridge-ext.jar for Liferay 7.
        Hide
        Mircea Toma added a comment - - edited

        The issue is caused by the refactoring in Liferay code base. com.liferay.portal.util.PortalUtil and com.liferay.portal.theme.ThemeDisplay classes that EnvUtils loos up are located at com.liferay.portal.kernel.util.PortalUtil and com.liferay.portal.kernel.theme.ThemeDisplay.

        The lookup code in org.icefaces.util.EnvUtils will now fallback into using com.liferay.portal.kernel package as root package when running in Liferay 7.*.

        Show
        Mircea Toma added a comment - - edited The issue is caused by the refactoring in Liferay code base. com.liferay.portal.util.PortalUtil and com.liferay.portal.theme.ThemeDisplay classes that EnvUtils loos up are located at com.liferay.portal.kernel.util.PortalUtil and com.liferay.portal.kernel.theme.ThemeDisplay . The lookup code in org.icefaces.util.EnvUtils will now fallback into using com.liferay.portal.kernel package as root package when running in Liferay 7.*.
        Hide
        Neil Griffin added a comment -

        Successfully tested on Liferay Portal 7.0-B7, Liferay Portal 6.2.5, and Pluto 2.0.2 using Liferay Faces Bridge 4.0.0-SNAPSHOT (new version scheme).

        Show
        Neil Griffin added a comment - Successfully tested on Liferay Portal 7.0-B7, Liferay Portal 6.2.5, and Pluto 2.0.2 using Liferay Faces Bridge 4.0.0-SNAPSHOT (new version scheme).
        Hide
        Carmen Cristurean added a comment -

        Verified ICEfaces 4.1.1 Jenkins Build #6, showcase > fileEntry demos on Tomcat8.0.21/ IE11.

        Show
        Carmen Cristurean added a comment - Verified ICEfaces 4.1.1 Jenkins Build #6, showcase > fileEntry demos on Tomcat8.0.21/ IE11.

          People

          • Assignee:
            Mircea Toma
            Reporter:
            Neil Griffin
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: