ajax not working – apache before glassfish

Splash Forums Rewrite Users ajax not working – apache before glassfish

This topic contains 3 replies, has 2 voices, and was last updated by  Christian Kaltepoth 2 years, 11 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #24732

    djmj
    Participant

    I use apache as a reverse-proxy before glassfish and when I am trying to proxy-pass to a rewritten subfolder instead of the main I get following problem.

    All ajax calls aren’t working anymore resulting in a 500 Internal Server Error.

    When I will proxy-pass to the main folder i get no problems.

    JSF – Rewriterules:

    Using http://ocpsoft.org/ rewrite solution to create the virtual url the apache shall proxy too:

    /foo/{fooViewParamValue} -> /sites/foo/foo.xhtml

    Apache config:

    <VirtualHost *>
    ProxyRequests Off

    <proxy *>
    Order deny,allow
    # Deny from all
    Allow from all
    </proxy>

    SetOutputFilter proxy-html
    ProxyPreserveHost On

    # map resources
    ProxyPass /res/ http://localhost:2080/res/
    ProxyPassReverse /res/ http://localhost:2080/res/
    # map subfolder
    ProxyPass / http://localhost:2080/foo/fooViewParamValue/
    ProxyPassReverse / http://localhost:2080/foo/fooViewParamValue/
    # map main folder – test
    #ProxyPass / http://localhost:2080/
    #ProxyPassReverse / http://localhost:2080/

    # map processed html elements
    ProxyHTMLLinks a href
    ProxyHTMLLinks area href
    ProxyHTMLLinks link href
    ProxyHTMLLinks img src longdesc usemap
    ProxyHTMLLinks object classid codebase data usemap
    ProxyHTMLLinks q cite
    ProxyHTMLLinks blockquote cite
    ProxyHTMLLinks ins cite
    ProxyHTMLLinks del cite
    ProxyHTMLLinks form action
    ProxyHTMLLinks input src usemap
    ProxyHTMLLinks head profile
    ProxyHTMLLinks base href
    ProxyHTMLLinks script src for

    # map processed html events
    ProxyHTMLEvents onclick ondblclick onmousedown onmouseup \
    onmouseover onmousemove onmouseout onkeypress \
    onkeydown onkeyup onfocus onblur onload \
    onunload onsubmit onreset onselect onchange

    ProxyHTMLEnable On
    ProxyHTMLExtended On

    # main folder html
    #ProxyHTMLURLMap / /
    # subfolder html
    ProxyHTMLURLMap /foo/fooViewParamValue/ /
    ProxyHTMLURLMap /foo/fooViewParamValue /
    </VirtualHost>

    Observation:

    Sometimes it is enough to remove the content of the form action attribute (in firebug) to make it work, but sometimes the exception is looged in an endless loop:

    <h:form>
    <p:commandButton/>
    </h:form>
    <!– final html –>
    <form action=”/sites/foo/foo.xhtml”>
    <button/>
    </form>
    <!– removing action content sometimes works –>
    <form action=””>
    <button/>
    </form>

    Exception that is logged:

    Sometimes once, sometimes in a loop:

    Warnung: StandardWrapperValve[Faces Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw exception
    java.lang.NullPointerException
    at com.sun.faces.context.PartialViewContextImpl.createPartialResponseWriter(PartialViewContextImpl.java:439)
    at com.sun.faces.context.PartialViewContextImpl.access$300(PartialViewContextImpl.java:72)
    at com.sun.faces.context.PartialViewContextImpl$DelayedInitPartialResponseWriter.getWrapped(PartialViewContextImpl.java:573)
    at javax.faces.context.PartialResponseWriter.startDocument(PartialResponseWriter.java:115)
    at org.omnifaces.context.OmniPartialViewContext$OmniPartialResponseWriter.startDocument(OmniPartialViewContext.java:252)
    at org.primefaces.context.PrimePartialResponseWriter.startDocument(PrimePartialResponseWriter.java:133)
    at com.sun.faces.context.AjaxExceptionHandlerImpl.handlePartialResponseError(AjaxExceptionHandlerImpl.java:199)
    at com.sun.faces.context.AjaxExceptionHandlerImpl.handle(AjaxExceptionHandlerImpl.java:124)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119)
    at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1542)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    at package.HttpHeaderFilter.doFilter(HttpHeaderFilter.java:48)
    at org.omnifaces.filter.HttpFilter.doFilter(HttpFilter.java:75)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    at org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:199)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:722)

    Edit1:

    I removed //Rewrite and mapped to the physical subfolder from apache and had no problems.
    Since mapping works without using ocp rewrite without a problem. Rewrite itself must be the reason.

    Edit2:

    Moving back to predecessor PrettyFaces it works without problems.

    • This topic was modified 2 years, 11 months ago by  djmj.
    • This topic was modified 2 years, 11 months ago by  djmj. Reason: implemented so question
    #24736

    It looks a bit strange for me that the form postback URL is /sites/foo/foo.xhtml instead of. It should be /foo/whatevery instead. Could you show us the Rewrite dependencies you added to your project. You should include either rewrite-integration-faces or rewrite-config-prettyfaces for getting full JSF support. Which of the two to choose depends on whether you want to reuse and existing PrettyFaces configuration, or if you want to use the plain Rewrite configuration. See this part of the documentation for details:

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

    #24741

    djmj
    Participant

    Oh man great thanks. I did not thought this would be an issue but the unmapped form url was an issue:

    The postback url of the form is /sites/foo/foo.xhtml and was unmapped.

    I thought I do not need to map it because in my bean logic a redirect takes place if the view-parameter is not provided. But the form uses the raw view-id without view-parameters.

    For the solution I did not added any of the above modules. The migration guide is contradictary to the install guide http://ocpsoft.org/rewrite/docs/configuration/install where only the rewrite-servlet must be added, which was sufficient for me.

    • 1. Map the form url using rewrite rule: cb.addRule(Join.path("/foo/").to("/sites/foo/foo.xhtml"));
    • 2. Add the ProxyHTMLURLMap /foo/ / to apache proxy config

    Rewritten on proxy this will result into form src /. Empty could also be possible removing trailing slash from pattern.

    Curious: Why was it working with pretty-faces where this rule was also not mapped?

    #24745

    Just a note on this. Yeah, the installation guide only mentions rewrite-servlet, but if you want the JSF support, you will have to add one of the other modules. The installation guide describes the setup for a plain Servlet environment. If you are using Rewrite in a JSF environment, you should stick to the description in the PrettyFaces migration guide.

    Regarding your question. What do you mean with “not mapped”. I think with PrettyFaces you had a URL-mapping for the URL (pretty-config.xml or annotations), right? With Rewrite you will of cause also have to map the URL somehow. And this is done by an addRule() call like you mentioned it in your post.

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

You must be logged in to reply to this topic.

Comments are closed.