Asynch Request with

Splash Forums PrettyFaces Users Asynch Request with

This topic contains 18 replies, has 4 voices, and was last updated by  Lincoln Baxter III 6 years, 8 months ago.

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

    s33d
    Participant

    When PrettyFaces are enabled – asynch servlets are not working. Please try to create servlet with asynch, then startAsynch and use it.

    java.lang.IllegalStateException: Request is within the scope of a filter or servlet that does not support asynchronous operations

    at org.apache.catalina.connector.Request.startAsync(Request.java:3657)

    at org.apache.catalina.connector.Request.startAsync(Request.java:3633)

    at org.apache.catalina.connector.RequestFacade.startAsync(RequestFacade.java:1053)

    ()

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)

    at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:113)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)

    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:277)

    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)

    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)

    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)

    at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)

    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)

    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)

    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)

    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)

    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)

    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)

    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)

    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)

    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)

    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)

    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)

    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)

    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)

    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)

    at com.sun.grizzly.ContextTask.run(ContextTask.java:69)

    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)

    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)

    at java.lang.Thread.run(Thread.java:619)

    #20192

    Could you please post some more details of your environment, your configuration and the libraries you use?

    #20193

    s33d
    Participant

    JEE 6 with PrimeFaces on Glassfish v3. Everythig works ok. When I add PrettyFaces to pom and deploy the application – requests to Servlets that starts asynch generates error that I posted. It would be ok I coud add exception for specific URL or if PrettyFilter can recongize asynch requests.

    #20194

    PrettyFaces automatically configures itself in a JEE 6 via web-fragment.xml environment like this:

    <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>
    </filter-mapping>

    I think the url-pattern is causing problems for you. Maybe you could manually configure the PrettyFilter in your web.xml and change the url-pattern to something like *.jsf. AFAIK this will overwrite the configuration from the web-fragment.xml file.

    #20195

    s33d
    Participant

    I have changed it in web-fragment.xml (edited it through war) – now asynch is working but URL are not. I get 404 when accesing any of defined in pretty-config view-id’s

    #20196

    You don’t want to use “*.jsf”

    You want to map PrettyFilter to the resources you want to be intercepted (your pretty URLs,) and you want to prevent mapping to resources you *dont* want intercepted.

    Using *.jsf means that PrettyFilter is only going to map requests that are going to JSF anyway, and probably isn’t what you want.

    #20197

    Does that help? I can be more specific if you like.

    Also, I’m intrigued that Async does not work w/PrettyFaces, I’d like to figure that out. Any chance you could send us a sample app that we could debug?

    –Lincoln

    #20198

    Also remember, you can have more than one FilterMapping for the same Filter.

    #20199

    You are right! *.jsf was not a really good example. I was trying to say that you should change the URL pattern to something more restrictive than /* by using some kind of path prefix or file extension mapping.

    @lincoln:

    I’m not an expert on async servlets but the exception message sounds as if filters aren’t allowed in context of an async invocation. Any ideas?

    #20200

    s33d
    Participant

    You don’t want to use “*.jsf” <– yes – I understand now – THANKS! It helped me in finding this solution:

    solution for now is to change EVERY pattern in pretty-config by adding prefix /page like:

    /page/news/, /page/documents/ (instead of /news/, /documents/) and then changing in pretty web-fragment pattern to /page/* so that FacesFilter works only for such requests.

    By doing it I can make exception for my servlet which listens on:

    /asynchMessagesWatcher <– FacesFilter wont be chained here and everything works ok.

    I am sorry but I cannot provide any sample app. Try just to create Servlet with asynch addnotation and method:

    public void doGet(HttpServletRequest request, HttpServletResponse res) {

    request.startAsync(request, res);}

    #20201

    Great that its working for you now! Sorry for my confusing suggestion! :-)

    #20202

    s33d
    Participant

    Yes but its only a workaround :)

    #20203

    That’s correct! :-)

    Could you try to declare the PrettyFilter like this:

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

    I don’t know if the PrettyFaces code has to be modified to support async-supported=true, but you could try if it works this way! :-)

    #20204

    s33d
    Participant

    it works: (changed in web-fragment)

    <async-supported>true</async-supported>

    Any chances it will be included in future release ?

    Thanks a lot!

    #20205

    Great! :-)

    I did a quick check with Tomcat 7.0.2 and it also seems to work. But only with a very simple async example.

    I will have a deeper look at this in the next days. I want to make sure that PrettyFaces works this way without further problems.

    Please let us know if you see any strange stuff happening in your app! :-)

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

You must be logged in to reply to this topic.

Comments are closed.