2014-04-04 191 views
1

我知道這個問題已經提出了很多次,並且我已經閱讀了Google的論壇帖子頁面,但我仍然沒有找到明確的解決方案。問題是,一些primefaces資源無法送達導致超時異常:JSF1064:Primefaces無法加載資源

JSF1064:無法找到或服務資源,日程/ schedule.js,從圖書館,primefaces。 java.io.IOException:java.util.concurrent.TimeoutException

錯誤並不總是針對某個特定資源,它可能很多(大部分時間是schedule.js),並且它只發生〜 60%的時間。

我甚至嘗試手動輸出腳本和css文件無濟於事。所有的primefaces jar都位於相應的WEB-INF/lib文件夾中。

web.xml中:

<?xml version="1.0" encoding="UTF-8"?> <web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"> <context-param> <param-name>javax.faces.PROJECT_STAGE</param-name> <param-value>Development</param-value> </context-param>
<context-param> <param-name>primefaces.THEME</param-name> <param-value>home</param-value> </context-param> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.xhtml</url-pattern> <url-pattern>*.jsf</url-pattern> </servlet-mapping> <session-config> <session-timeout> 30 </session-timeout> </session-config> <welcome-file-list> <welcome-file>index.xhtml</welcome-file> </welcome-file-list> </web-app>

堆棧跟蹤:

WARNING: JSF1064: Unable to find or serve resource, schedule/schedule.js, from library, primefaces. 
    WARNING: java.io.IOException: java.util.concurrent.TimeoutException 
    at org.glassfish.grizzly.utils.Exceptions.makeIOException(Exceptions.java:81) 
    at  org.glassfish.grizzly.http.io.OutputBuffer.blockAfterWriteIfNeeded(OutputBuffer.java:958) 
    at org.glassfish.grizzly.http.io.OutputBuffer.write(OutputBuffer.java:682) 
    at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:355) 
    at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:342) 
    at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:161) 
    at java.nio.channels.Channels$WritableByteChannelImpl.write(Channels.java:458) 
    at com.sun.faces.application.resource.ResourceHandlerImpl.handleResourceRequest(ResourceHandler Impl.java:343) 
    at java x.faces.application.ResourceHandlerWrapper.handleResourceRequest(ResourceHandlerWrapper.java:153) 
    at org.primefaces.application.PrimeResourceHandler.handleResourceRequest(PrimeResourceHandler.java:132) 
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:643) 
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682) 
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318) 
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160) 
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734) 
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673) 
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99) 
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174) 
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357) 
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260) 
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188) 
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191) 
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168) 
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189) 
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114) 
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) 
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838) 
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113) 
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115) 
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55) 
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135) 
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564) 
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544) 
    at java.lang.Thread.run(Thread.java:722) 
Caused by: java.util.concurrent.TimeoutException 
    at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:258) 
    at java.util.concurrent.FutureTask.get(FutureTask.java:119) 
    at org.glassfish.grizzly.http.io.OutputBuffer.blockAfterWriteIfNeeded(OutputBuffer.java:951) 
    ... 36 more 
+1

我想你可以刪除你的JSF代碼,並提供服務器配置的詳細信息,因爲它看起來像一個服務器值。爲了確保產生錯誤的地方,堆棧跟蹤的適當部分也是必要的,但幾乎可以確定它是服務器代碼,而不是PrimeFaces代碼。 –

+0

我添加了stacktrace和web.xml文件以供參考。 –

+0

不幸的是,我不知道Glassfish。刪除CSS標籤並添加玻璃魚一個。 –

回答

1

這個問題記錄爲Glassfish的錯誤#20681。這是Glassfish 4中Grizzly(HTTP服務器)版本的一個問題。

存在導致問題的兩個問題。首先是小套接字寫緩衝區大小。 RH和Ubuntu的默認寫入緩衝區大小爲16K。在灰熊,爲了節省內存,在阻止寫入器之前,只有 允許4倍的寫入緩衝區大小排隊。在附加測試用例的情況下,有幾個工件超過200K。寫入這些內容後,默認Servlet所做的初始寫入將超出最大隊列數據大小,並導致寫入器阻塞。因爲所有工作線程都被阻塞,所以異步寫隊列不再被排空,就用戶而言,頁面在加載時會掛起。這是第二個問題的出處。默認情況下,只有五個工作線程。在測試案例中,至少有五個請求正在請求大量資源。由於這個原因,所有工作線程都被阻塞,所有I/O都停止。

由於觀察到,增加了GF使用寫緩衝區大小,有助於緩解這個問題,但在每個連接存儲的成本。也可以增加線程的數量,但不能保證所有這些線程在升級客戶端數量時最終都不會被阻塞。

+0

這是正確的答案!我看到一箇舊帖子,建議增加線程數,這對我的特定情況起作用。謝謝你的迴應。我在本週到期的學校項目中使用primefaces,你的答案是非常好的時機! –