Pretty & PrimeFaces FileUpload

Splash Forums PrettyFaces Users Pretty & PrimeFaces FileUpload

This topic contains 18 replies, has 5 voices, and was last updated by  Christian Kaltepoth 1 year, 9 months ago.

Viewing 15 posts - 1 through 15 (of 19 total)
  • Author
    Posts
  • #25639

    brasmouk
    Participant

    Hello,
    I use prettyfaces-jsf2-.3.3.3 and primefaces-4.0 with the following configuration web.xml

    
        <filter>
            <filter-name>Pretty Filter</filter-name>
            <filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
        </filter>
        <filter-mapping>
            <filter-name>Pretty Filter</filter-name>
            <url-pattern>/*</url-pattern>
            <dispatcher>FORWARD</dispatcher>
            <dispatcher>REQUEST</dispatcher>
            <dispatcher>ERROR</dispatcher>
            <dispatcher>ASYNC</dispatcher>
        </filter-mapping>
    
       <filter>
    	<filter-name>PrimeFaces FileUpload Filter</filter-name>
    	<filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
       </filter>
       <filter-mapping>
            <filter-name>PrimeFaces FileUpload Filter</filter-name>
    	<url-pattern>/*</url-pattern>
    	<servlet-name>Faces Servlet</servlet-name>
    	<dispatcher>FORWARD</dispatcher>
       </filter-mapping>
    
    
    	<h:form id="form" enctype="multipart/form-data">
       	    <p:fileUpload fileUploadListener="#{fileUploadController.upload}"
    			ajax="false" sizeLimit="1000000" />
    	</h:form>
    

    but it does not work.

    it works very well without having to configure pretty !

    Any idea?

    #25643

    ravindra
    Participant

    Please add following content in webapp folder under META-INF folder (webapp/META-INF/context.xml)

    <Context allowCasualMultipartParsing=”true”>
    <!– no content required –>
    </Context>

    #25645

    brasmouk
    Participant

    not work with context.xml !

    I recall that it works well without “pretty-config”

    #25646

    Which container are you using?

    #25647

    brasmouk
    Participant

    Container jsf ?

    #25648

    No, which container do you deploy to? Tomcat? Glassfish? JBoss AS7? Wildfly?

    #25649

    brasmouk
    Participant

    WildFly 8.0

    • This reply was modified 2 years, 7 months ago by  brasmouk.
    #25653

    Additionally, PrettyFaces 3.3.3 is out of date. You should be using rewrite and rewrite-config-prettyfaces 2.0.9.Final: Could you try that and see if the problem persists?

    Instructions can be found here:
    http://ocpsoft.org/prettyfaces/

    #25654

    I agree with Lincoln. You should think about migrating to Rewrite. Have a look at the following migration guide for details:

    http://ocpsoft.org/rewrite/docs/migration/prettyfaces3

    Another thing. As you are using Wildfly, the context.xml workaround won’t work for your. Wildfly is using Undertow as the Servlet container and the context.xml workaround works only on Tomcat. I’m not sure if there is a way to work around this problem in Undertow. Perhaps you should ask this question in the Wildfly/Undertow forums? Have a look at the Rewrite FAQ entry for this for more details on the issue.

    http://ocpsoft.org/rewrite/docs/faq

    #25708

    brasmouk
    Participant

    I added

    com.ocpsoft:prettyfaces-jsf2:3.3.3
    org.ocpsoft.rewrite:rewrite-servlet: 2.0.9.Final
    org.ocpsoft.rewrite:rewrite-config-prettyfaces: 2.0.9.Final

    and I configure web.xml

    <filter>
    <filter-name> OCPsoft Rewrite Filter </ filter-name>
    <filter-class> org.ocpsoft.rewrite.servlet.RewriteFilter </ filter-class>
    <async-supported> true </ async-supported>
    </ filter>

    <filter-mapping>
    <filter-name> OCPsoft Rewrite Filter </ filter-name>
    <url-pattern> / * </ url-pattern>
    <dispatcher> FORWARD </ dispatcher>
    <dispatcher> REQUEST </ dispatcher>
    <dispatcher> INCLUDE </ dispatcher>
    <dispatcher> ASYNC </ dispatcher>
    <dispatcher> ERROR </ dispatcher>
    </ filter-mapping>

    but I get the following error:

    
    ERROR [io.undertow.request] (default task-3) Servlet request failed HttpServerExchange{ GET /ice-web/pages/public/login.xhtml}: java.lang.NoSuchMethodError: com.ocpsoft.pretty.faces.config.reload.PrettyConfigReloader.reloadIfNecessary(Ljavax/servlet/ServletContext;)V
    	at org.ocpsoft.rewrite.prettyfaces.PrettyFacesRewriteLifecycleListener.beforeInboundLifecycle(PrettyFacesRewriteLifecycleListener.java:51) [rewrite-config-prettyfaces-2.0.9.Final.jar:2.0.9.Final]
    	at org.ocpsoft.rewrite.prettyfaces.PrettyFacesRewriteLifecycleListener.beforeInboundLifecycle(PrettyFacesRewriteLifecycleListener.java:34) [rewrite-config-prettyfaces-2.0.9.Final.jar:2.0.9.Final]
    	at org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:175) [rewrite-servlet-2.0.9.Final.jar:2.0.9.Final]
    	at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:56) [undertow-servlet-1.0.0.Beta17.jar:1.0.0.Beta17]
    	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132) [undertow-servlet-1.0.0.Beta17.jar:1.0.0.Beta17]
    	at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:85) [undertow-servlet-1.0.0.Beta17.jar:1.0.0.Beta17]
    	at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:57) [undertow-servlet-1.0.0.Beta17.jar:1.0.0.Beta17]
    	at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) [undertow-servlet-1.0.0.Beta17.jar:1.0.0.Beta17]
    	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.0.Beta17.jar:1.0.0.Beta17]
    	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.0.Beta17.jar:1.0.0.Beta17]
    	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.0.Beta17.jar:1.0.0.Beta17]
    	at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:207) [undertow-servlet-1.0.0.Beta17.jar:1.0.0.Beta17]
    	at io.undertow.servlet.handlers.ServletInitialHandler.dispatchToPath(ServletInitialHandler.java:150) [undertow-servlet-1.0.0.Beta17.jar:1.0.0.Beta17]
    	at io.undertow.servlet.spec.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:157) [undertow-servlet-1.0.0.Beta17.jar:1.0.0.Beta17]
    	at io.undertow.servlet.handlers.security.ServletFormAuthenticationMechanism.servePage(ServletFormAuthenticationMechanism.java:39) [undertow-servlet-1.0.0.Beta17.jar:1.0.0.Beta17]
    	at io.undertow.security.impl.FormAuthenticationMechanism.sendChallenge(FormAuthenticationMechanism.java:156) [undertow-core-1.0.0.Beta17.jar:1.0.0.Beta17]
    	at io.undertow.security.impl.SecurityContextImpl$ChallengeSender.transition(SecurityContextImpl.java:331) [undertow-core-1.0.0.Beta17.jar:1.0.0.Beta17]
    	at io.undertow.security.impl.SecurityContextImpl$ChallengeSender.transition(SecurityContextImpl.java:350) [undertow-core-1.0.0.Beta17.jar:1.0.0.Beta17]
    	at io.undertow.security.impl.SecurityContextImpl$ChallengeSender.access$300(SecurityContextImpl.java:315) [undertow-core-1.0.0.Beta17.jar:1.0.0.Beta17]
    	at io.unde
    
    
    • This reply was modified 2 years, 7 months ago by  brasmouk.
    • This reply was modified 2 years, 7 months ago by  brasmouk.
    #25711

    Please remove this artifact:

    com.ocpsoft:prettyfaces-jsf2:3.3.3

    This is the old version of PrettyFaces. You don’t need it any more if you include Rewrite + rewrite-config-prettyfaces

    #25712

    brasmouk
    Participant

    the setting pretty-config.xml does not work

    Here is what I have at startup

    
    12:51:54,837 INFO  [org.ocpsoft.rewrite.servlet.RewriteFilter] (default task-2) RewriteFilter starting up...
    12:51:54,852 INFO  [org.ocpsoft.rewrite.servlet.RewriteFilter] (default task-2) Loaded [4] org.ocpsoft.rewrite.servlet.spi.RewriteLifecycleListener [org.ocpsoft.rewrite.prettyfaces.PrettyFacesRewriteLifecycleListener<-100>, org.ocpsoft.rewrite.faces.FacesRewriteLifecycleListener<0>, org.ocpsoft.rewrite.servlet.impl.DefaultRewriteLifecycleListener<2147483647>, org.ocpsoft.rewrite.servlet.config.lifecycle.JoinRewriteLifecycleListener<2147483647>]
    12:51:54,853 INFO  [org.ocpsoft.rewrite.servlet.RewriteFilter] (default task-2) Loaded [1] org.ocpsoft.rewrite.servlet.spi.RequestCycleWrapper [org.ocpsoft.rewrite.servlet.impl.HttpRewriteRequestCycleWrapper<0>]
    12:51:54,853 INFO  [org.ocpsoft.rewrite.servlet.RewriteFilter] (default task-2) Loaded [1] org.ocpsoft.rewrite.spi.RewriteProvider [org.ocpsoft.rewrite.servlet.impl.DefaultHttpRewriteProvider<0>]
    12:51:54,853 INFO  [org.ocpsoft.rewrite.servlet.RewriteFilter] (default task-2) Loaded [1] org.ocpsoft.rewrite.spi.RewriteResultHandler [org.ocpsoft.rewrite.servlet.impl.HttpRewriteResultHandler<0>]
    12:51:54,854 INFO  [org.ocpsoft.rewrite.servlet.RewriteFilter] (default task-2) Loaded [1] org.ocpsoft.rewrite.servlet.spi.InboundRewriteProducer [org.ocpsoft.rewrite.servlet.impl.HttpInboundRewriteProducer<0>]
    12:51:54,854 INFO  [org.ocpsoft.rewrite.servlet.RewriteFilter] (default task-2) Loaded [1] org.ocpsoft.rewrite.servlet.spi.OutboundRewriteProducer [org.ocpsoft.rewrite.servlet.impl.HttpOutboundRewriteProducer<0>]
    12:51:54,855 INFO  [org.ocpsoft.rewrite.servlet.RewriteFilter] (default task-2) Loaded [1] org.ocpsoft.rewrite.servlet.spi.ContextListener [org.ocpsoft.rewrite.prettyfaces.PrettyConfigContextListener<0>]
    12:51:54,857 INFO  [org.ocpsoft.rewrite.servlet.RewriteFilter] (default task-2) Loaded [0] org.ocpsoft.rewrite.servlet.spi.RequestListener []
    12:51:54,858 INFO  [org.ocpsoft.rewrite.servlet.RewriteFilter] (default task-2) Loaded [1] org.ocpsoft.rewrite.servlet.spi.RequestParameterProvider [org.ocpsoft.rewrite.prettyfaces.PrettyFacesRequestParameterProvider<0>]
    12:51:54,860 INFO  [org.ocpsoft.rewrite.servlet.RewriteFilter] (default task-2) Loaded [1] org.ocpsoft.rewrite.el.spi.ExpressionLanguageProvider [org.ocpsoft.rewrite.faces.FacesExpressionLanguageProvider<30>]
    12:51:54,861 INFO  [org.ocpsoft.rewrite.servlet.RewriteFilter] (default task-2) Loaded [1] org.ocpsoft.rewrite.spi.InvocationResultHandler [org.ocpsoft.rewrite.faces.NavigatingInvocationResultHandler<100>]
    12:51:54,862 INFO  [org.ocpsoft.rewrite.servlet.RewriteFilter] (default task-2) Loaded [0] org.ocpsoft.common.spi.ServiceEnricher []
    12:51:54,865 INFO  [org.ocpsoft.rewrite.servlet.RewriteFilter] (default task-2) Loaded [1] org.ocpsoft.rewrite.spi.ConfigurationCacheProvider [org.ocpsoft.rewrite.servlet.impl.ServletContextConfigurationCacheProvider<0>]
    12:51:54,868 INFO  [org.ocpsoft.rewrite.servlet.RewriteFilter] (default task-2) Loaded [2] org.ocpsoft.rewrite.config.ConfigurationProvider [org.ocpsoft.rewrite.prettyfaces.PrettyFacesRewriteConfigurationProvider<1>, org.ocpsoft.rewrite.annotation.config.AnnotationConfigProvider<100>]
    12:
    
    • This reply was modified 2 years, 7 months ago by  brasmouk.
    • This reply was modified 2 years, 7 months ago by  brasmouk.
    #25715

    Could you explain “does not work” a bit more?

    #25727

    brasmouk
    Participant

    I replaced pretty-config.xml by this java class

    
    @RewriteConfiguration
    public class MyConfigurationProvider extends HttpConfigurationProvider {
    
      @Override
      public Configuration getConfiguration(ServletContext context) {
        return ConfigurationBuilder.begin()
    
        .addRule(Join.path("/app").to("/pages/protected/user/app.xhtml"));
      }
    
      @Override
      public int priority() {
        // TODO Auto-generated method stub
        return 10;
      }
    
    }
    
    

    Url mapping works now

    But PrimeFaces FileUpload still does not work !!

    In my web.xml

    
    	<filter>
    		<filter-name>PrimeFaces FileUpload Filter</filter-name>
    		<filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
    	</filter>
    	<filter-mapping>
    		<filter-name>PrimeFaces FileUpload Filter</filter-name>
    		<url-pattern>/*</url-pattern>
    		<servlet-name>Faces Servlet</servlet-name>
    		<dispatcher>FORWARD</dispatcher>
    		<dispatcher>REQUEST</dispatcher>
    		<dispatcher>INCLUDE</dispatcher>
    		<dispatcher>ASYNC</dispatcher>
    		<dispatcher>ERROR</dispatcher>
    
    	</filter-mapping>
    
    	<filter>
    		<filter-name>OCPsoft Rewrite Filter</filter-name>
    		<filter-class>org.ocpsoft.rewrite.servlet.RewriteFilter</filter-class>
    		<async-supported>true</async-supported>
    	</filter>
    	<filter-mapping>
    		<filter-name>OCPsoft Rewrite Filter</filter-name>
    		<url-pattern>/*</url-pattern>
                    <dispatcher>FORWARD</dispatcher>
    		<dispatcher>REQUEST</dispatcher>
    	</filter-mapping>
    
    • This reply was modified 2 years, 7 months ago by  brasmouk.
    • This reply was modified 2 years, 7 months ago by  brasmouk.
    • This reply was modified 2 years, 7 months ago by  brasmouk.
    #25731

    Could you perhaps provide a minimal Maven project to reproduce this problem? It’s difficult to tell what is wrong without having access to source code that reproduces this problem.

Viewing 15 posts - 1 through 15 (of 19 total)

You must be logged in to reply to this topic.

Comments are closed.