0

我在 glassfish 之前使用 apache 作为反向代理,当我尝试代理传递到重写的子文件夹而不是主文件夹时,我遇到了以下问题。

所有 ajax 调用都不再起作用,导致500 Internal Server Error.

当我将代理传递到主文件夹时,我没有遇到任何问题。

JSF - 重写规则:

使用http://ocpsoft.org/重写解决方案来创建 apache 也应代理的虚拟 url:

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

阿帕奇配置:

<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>

观察:

有时删除表单操作属性的内容(在 firebug 中)就足以使其工作,但有时异常会陷入无限循环:

<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>

记录的异常:

有时一次,有时循环:

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)

编辑1:

//Rewrite从 apache 删除并映射到物理子文件夹,没有问题。由于映射工作没有使用ocp rewrite没有问题。重写本身一定是原因。

编辑2:

回到前身PrettyFaces,它可以毫无问题地工作。

4

1 回答 1

0

//Rewrite论坛上我得到了答案:

表单 url 未映射,导致传递代理时 url 无效。

表单的回发 url/sites/foo/foo.xhtml未映射。没有视图参数。

  1. 使用重写规则映射表单 url:cb.addRule(Join.path("/foo/").to("/sites/foo/foo.xhtml")
  2. 添加ProxyHTMLURLMap /foo/ /到 apache 代理配置

在代理上重写这将导致表单 src /
Empty 也可以从模式中删除尾部斜杠。

好奇:它奇怪地适用于pretty-faces这个规则也没有映射的地方。

于 2013-08-30T23:15:31.330 回答