FileUpload problem with PrettyFaces 3.3.3 + RichFaces 3.3.3

Splash Forums PrettyFaces Users FileUpload problem with PrettyFaces 3.3.3 + RichFaces 3.3.3

This topic contains 9 replies, has 3 voices, and was last updated by  Lincoln Baxter III 5 years, 6 months ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #18212

    bhl
    Participant

    Hi,

    I’m having some problems with file upload.

    My environment:

    JSF 1.2

    Seam 2.2.2

    RichFaces 3.3.3

    PrettyFaces 3.3.3

    WebSphere 6.1

    fileUploadListener only gets called when pretty-config.xml is:

    <url-mapping id="upload">
    <pattern value="/upload.seam" />
    <view-id value="/upload.seam" />
    </url-mapping>

    If I change pattern value to “/upload” it does not work anymore.

    One interesting issue: in one of my attempts changing the order of web.xml filters, suddenly a ClassCastException ocurred. StackTrace: http://pastie.org/3578309

    So I’ve changed PrettyFacesWrappedRequest.getParameter(final String name) to

    Object obj = getParameterMap().get(name);
    if (obj instanceof String) {
    return (String) obj;
    }

    String[] strings = getParameterMap().get(name);
    if (strings != null)
    {
    return strings[0];
    }

    And with that code, the upload is working.

    Does anyone have a suggestion?

    Thanks a lot!

    #22228

    bhl
    Participant

    web.xml

    <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <listener>
    <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
    </listener>

    <filter>
    <filter-name>PrettyFilter</filter-name>
    <filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
    </filter>
    <filter-mapping>
    <filter-name>PrettyFilter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>ERROR</dispatcher>
    </filter-mapping>

    <filter>
    <display-name>RichFaces Filter</display-name>
    <filter-name>richfaces</filter-name>
    <filter-class>org.ajax4jsf.Filter</filter-class>
    <init-param>
    <param-name>createTempFiles</param-name>
    <param-value>false</param-value>
    </init-param>

    <init-param>
    <param-name>maxRequestSize</param-name>
    <param-value>2100000</param-value>
    </init-param>

    <init-param>
    <param-name>forceparser</param-name>
    <param-value>false</param-value>
    </init-param>

    <init-param>
    <param-name>enable-cache</param-name>
    <param-value>true</param-value>
    </init-param>
    </filter>
    <filter-mapping>
    <filter-name>richfaces</filter-name>
    <servlet-name>FacesServlet</servlet-name>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>INCLUDE</dispatcher>
    </filter-mapping>

    <filter>
    <filter-name>SeamFilter</filter-name>
    <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
    <init-param>
    <param-name>createTempFiles</param-name>
    <param-value>false</param-value>
    </init-param>
    <init-param>
    <param-name>maxRequestSize</param-name>
    <param-value>2000000</param-value>
    </init-param>
    </filter>
    <filter-mapping>
    <filter-name>SeamFilter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>ERROR</dispatcher>
    </filter-mapping>

    <filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>
    <filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <servlet-name>FacesServlet</servlet-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>REQUEST</dispatcher>
    </filter-mapping>

    #22229

    Hey,

    thanks you very much for bringing this up. However this seems to be a bug in WebSphere. ServletRequest.getParameterMap() is specified to return Map<String,String[]>. See:

    http://docs.oracle.com/javaee/6/api/javax/servlet/ServletRequest.html#getParameterMap()

    I don’t know exactly what is going wrong here, but it seems like WebSphere is doing something wrong here. Do you know if this is a known bug or something like this?

    Christian

    #22230

    bhl
    Participant

    Hello Christian,

    Strange, but same problem occurs with this war deployed in JBoss AS 7.1.0. Maybe my filters are crazy :(

    I don’t know if it is a WebSphere 6.1 (JEE 1.5) bug, but I have another interesting fact: debugging PrettyFacesWrappedRequest class in WebSphere, when super.getParameterMap() has “javax.faces.ViewState” key with “j_id2” value, ClassCastException occurs.

    HttpServletRequestWrapper.getParameterMap() contents:

    {javax.faces.ViewState=j_id2, formFile:j_id116=true, _richfaces_upload_uid=[Ljava.lang.String;@bca0bca, formFile=formFile, AJAXREQUEST=[Ljava.lang.String;@dac0dac, formFile:arquivoDecoration:uploadArquivo=[Ljava.lang.String;@ca40ca4, _richfaces_upload_file_indicator=[Ljava.lang.String;@d320d32}

    HTML Source:

    <input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="j_id2" />

    Another web.xml attempt:

    <filter>
    <display-name>RichFaces Filter</display-name>
    <filter-name>richfaces</filter-name>
    <filter-class>org.ajax4jsf.Filter</filter-class>
    <init-param>
    <param-name>createTempFiles</param-name>
    <param-value>false</param-value>
    </init-param>

    <init-param>
    <param-name>maxRequestSize</param-name>
    <param-value>2100000</param-value>
    </init-param>

    <init-param>
    <param-name>forceparser</param-name>
    <param-value>false</param-value>
    </init-param>

    <init-param>
    <param-name>enable-cache</param-name>
    <param-value>true</param-value>
    </init-param>
    </filter>
    <filter-mapping>
    <filter-name>richfaces</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>INCLUDE</dispatcher>
    <dispatcher>ERROR</dispatcher>
    </filter-mapping>

    <filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>
    <filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>ERROR</dispatcher>
    </filter-mapping>

    <filter>
    <filter-name>PrettyFilter</filter-name>
    <filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
    </filter>
    <filter-mapping>
    <filter-name>PrettyFilter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>ERROR</dispatcher>
    </filter-mapping>

    Any clues? :o)

    Thanks a lot!

    Bruno

    #22231

    Hmmm, it doesn’t seem to be a WebSphere issue if this also happens on AS7. Very weird. Perhaps it is an JSF issue? Do you deploy the JSF implementation of your app or do you use the version the container provides?

    Would it be possible to provide a minimal sample app reproducing this. This would allow me to do some debugging on this.

    #22232

    bhl
    Participant

    Maybe an JSF issue, because I did not use the container version.

    jsf-impl.jar version: 1.2_12-b01-FCS

    I’ll try to make a minimal sample app.

    Thanks!

    #22233

    bhl
    Participant

    Christian,

    I need your help one more time…

    Please, take a look at line 666 (dammit) of this class:

    http://grepcode.com/file/repository.jboss.org/nexus/content/repositories/releases/org.richfaces.framework/richfaces-impl/3.3.3.Final/org/ajax4jsf/request/MultipartRequest.java

    Don’t you think that it is a problem?

    Best regards,

    Bruno

    #22234

    Hey Bruno,

    you are right. This looks suspicious. This really MAY cause the class cast exception you are seeing. But I’m not sure. You could try to debug what exactly is happening there. But IMHO this code looks really wrong.

    Christian

    #22235

    bhl
    Participant

    I’m asking for help here: https://community.jboss.org/message/723552

    Thanks for now!

    Bruno

    #22236

    Thanks Bruno,

    Please let us know what you find!

    ~Lincoln

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.

Comments are closed.