2

我收到一些抱怨说我的应用程序的 p:toolbar 不起作用。亲自查看其中一个问题发生的工作站,Firefox 49 控制台出现以下错误:

SyntaxError: missing ) after argument list[Learn More]components.js.jsf:21:18950

打开 components.js 我可以看到文件不完整,它在这一行停止加载:

PrimeFaces.widget.Menu=PrimeFaces.widget.BaseWidget.extend ...

PrimeFaces 版本是 6.0.5。

我想了解两点:

  1. 为什么会发生
  2. 如果发生这种情况,如何在应用程序中修复它

1)我的应用程序不向公众开放,所以用户看到的第一页是登录。当我更新 PrimeFaces 版本时,会在登录页面触发下载新版本的 components.js 对吗?我最好的猜测是用户已经在浏览器上保存了他的凭据并且他的连接很慢,所以当他提交登录表单时页面甚至没有完成加载,中止 components.js 下载,但由于该文件存在于本地浏览器尝试使用它。

考虑到问题存在一种模式(文件大约在中间停止加载),这可能是一些服务器问题吗?我正在使用 Apache TomEE 7.0.1(Tomcat 8.5.3)。服务器日志多次出现以下异常:

16-Oct-2016 22:08:08.469 SEVERE [http-nio-8080-exec-11] org.apache.myfaces.application.ResourceHandlerImpl.handleResourceRequest Error trying to load resource components.js with library primefaces :java.io.IOException: Pipe quebrado
 org.apache.catalina.connector.ClientAbortException: java.io.IOException: Pipe quebrado
    at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:380)
    at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:420)
    at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:329)
    at org.apache.catalina.connector.OutputBuffer.close(OutputBuffer.java:281)
    at org.apache.catalina.connector.CoyoteOutputStream.close(CoyoteOutputStream.java:150)
    at org.apache.myfaces.application.ResourceHandlerImpl.handleResourceRequest(ResourceHandlerImpl.java:620)
    at javax.faces.application.ResourceHandlerWrapper.handleResourceRequest(ResourceHandlerWrapper.java:59)
    at org.primefaces.application.resource.PrimeResourceHandler.handleResourceRequest(PrimeResourceHandler.java:87)
    at javax.faces.application.ResourceHandlerWrapper.handleResourceRequest(ResourceHandlerWrapper.java:59)
    at javax.faces.application.ResourceHandlerWrapper.handleResourceRequest(ResourceHandlerWrapper.java:59)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:190)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:100)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at org.apache.openejb.server.httpd.EEFilter.doFilter(EEFilter.java:65)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at br.com.spdata.filter.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:21)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108)
    at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:44)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:522)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.tomee.catalina.OpenEJBSecurityListener$RequestCapturer.invoke(OpenEJBSecurityListener.java:97)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1110)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:785)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1425)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: Pipe quebrado
    at sun.nio.ch.FileDispatcherImpl.write0(Native Method)
    at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47)
    at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93)
    at sun.nio.ch.IOUtil.write(IOUtil.java:65)
    at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471)
    at org.apache.tomcat.util.net.NioChannel.write(NioChannel.java:134)
    at org.apache.tomcat.util.net.NioBlockingSelector.write(NioBlockingSelector.java:101)
    at org.apache.tomcat.util.net.NioSelectorPool.write(NioSelectorPool.java:157)
    at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.doWrite(NioEndpoint.java:1241)
    at org.apache.tomcat.util.net.SocketWrapperBase.writeBlocking(SocketWrapperBase.java:355)
    at org.apache.tomcat.util.net.SocketWrapperBase.write(SocketWrapperBase.java:324)
    at org.apache.coyote.http11.Http11OutputBuffer$SocketOutputBuffer.doWrite(Http11OutputBuffer.java:580)
    at org.apache.coyote.http11.filters.ChunkedOutputFilter.doWrite(ChunkedOutputFilter.java:112)
    at org.apache.coyote.http11.Http11OutputBuffer.doWrite(Http11OutputBuffer.java:213)
    at org.apache.coyote.Response.doWrite(Response.java:502)
    at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:375)
    ... 43 more


17-Oct-2016 08:34:32.650 SEVERE [http-nio-8080-exec-8] org.apache.myfaces.application.ResourceHandlerImpl.handleResourceRequest Error trying to load resource components.js with library primefaces :Stream closed
 java.io.IOException: Stream closed
    at java.util.zip.InflaterInputStream.ensureOpen(InflaterInputStream.java:67)
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:142)
    at java.io.FilterInputStream.read(FilterInputStream.java:107)
    at org.apache.catalina.webresources.AbstractArchiveResource$JarInputStreamWrapper.read(AbstractArchiveResource.java:249)
    at org.apache.myfaces.application.ResourceHandlerImpl.pipeBytes(ResourceHandlerImpl.java:655)
    at org.apache.myfaces.application.ResourceHandlerImpl.handleResourceRequest(ResourceHandlerImpl.java:605)
    at javax.faces.application.ResourceHandlerWrapper.handleResourceRequest(ResourceHandlerWrapper.java:59)
    at org.primefaces.application.resource.PrimeResourceHandler.handleResourceRequest(PrimeResourceHandler.java:87)
    at javax.faces.application.ResourceHandlerWrapper.handleResourceRequest(ResourceHandlerWrapper.java:59)
    at javax.faces.application.ResourceHandlerWrapper.handleResourceRequest(ResourceHandlerWrapper.java:59)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:190)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:100)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at org.apache.openejb.server.httpd.EEFilter.doFilter(EEFilter.java:65)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at br.com.spdata.filter.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:21)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108)
    at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:44)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:522)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.tomee.catalina.OpenEJBSecurityListener$RequestCapturer.invoke(OpenEJBSecurityListener.java:97)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1110)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:785)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1425)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)

2)考虑到至少加载了 jQuery,我附带了以下脚本,但它不会替换损坏的缓存文件。

    <script type="text/javascript">
        //<![CDATA[
        $(document).ready(function()                     
        {                  
            try
            {
                var ctx = "#{request.contextPath}";

                if(typeof PrimeFaces == 'undefined')
                {
                    $.getScript(ctx + '/javax.faces.resource/core.js.jsf?ln=primefaces')
                }

                if(typeof PrimeFaces.widget.TriStateCheckbox == 'undefined') // last component on the file
                {
                    $.getScript(ctx + '/javax.faces.resource/components.js.jsf?ln=primefaces')
                }       
            }
            catch(e)
            {
                console.log(e);
            }       
        });             
        //]]>   
    </script>       
</h:body>

有任何想法吗?

提前致谢

4

1 回答 1

0

我遇到了同样的问题,因为我收到了相同的错误跟踪,而且它只发生在 Firefox 中。该错误表示未加载 Primefaces 的某些字体或样式,但验证应用程序似乎一切都已加载好,尽管显示了此错误。经过大量研究,我在这里发现了问题。

日志消息对应于 HTTP 请求,这些请求在提交后立即被取消,在服务器可以发送响应之前。“Cache Race With Red”功能在 Firefox 59(3 月 13 日发布)中被激活,这似乎是原因。

借助此功能,Firefox 可以同时向本地磁盘缓存和实际的网络服务器发送对缓存资源的请求。无论哪个结果先到达,都会取消另一个请求(这将导致有关“Broken pipe”的日志消息,与其他连接中止一样)。

可以在 Firefox 中通过设置禁用此about:config功能。因此,在将其设置为 false 后,我不再收到日志消息。在我的情况下,日志消息似乎是良性的,我可以忽略它。network.http.rcwn.enabledfalse

配置竞赛功能 Firefox

我希望这可以帮助遇到同样问题的其他人。

于 2020-02-14T11:54:41.223 回答