2011-12-07 59 views
2

我已經創建了一個簡單JSF2.0應用程序,它在我的電腦運行正常,但是當我嘗試在Heroku上運行它,我得到這個錯誤:顯示java.lang.NullPointerException在com.sun.faces.context.flash.ELFlash.getFlash

HTTP ERROR 500 

Problem accessing /login.xhtml. Reason: 

    Server Error 

Caused by: 

java.lang.NullPointerException 
    at com.sun.faces.context.flash.ELFlash.getFlash(ELFlash.java:93) 
    at com.sun.faces.context.flash.ELFlash.getELFlash(ELFlash.java:124) 
    at com.sun.faces.context.flash.ELFlash.doPostPhaseActions(ELFlash.java:722) 
    at com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:175) 
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:108) 
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) 
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:311) 
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:547) 
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:481) 
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119) 
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:520) 
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227) 
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:940) 
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:409) 
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:186) 
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:874) 
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117) 
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110) 
    at org.eclipse.jetty.server.Server.handle(Server.java:349) 
    at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:441) 
    at org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:904) 
    at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:565) 
    at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:217) 
    at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:46) 
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:545) 
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:43) 
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598) 
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533) 
    at java.lang.Thread.run(Thread.java:636) 

那麼,這個問題的解決方案? 在此先感謝。

+0

Mojarra是什麼版本? ELFlash#getELFlash()方法在2.0.0中不存在,直到使用當前的2.1.4。 – BalusC

+0

嗨。我使用的是2.0.0-b13,然後我嘗試了2.1.4,但我又遇到了一個錯誤。最後我改的MyFaces和它的作品,但它無法讀取註釋(!?),我必須每託管bean /屬性格式添加到faces-config.xml中。 在任何情況下,它的工作原理在這裏MT電腦,但不是在Heroku上。 我認爲問題是依賴關係,我使用的是Maven 3.0.3。什麼是jsf的正確依賴關係? –

+0

Mojarra 2.1.x需要Servlet 3.0。目前尚不清楚你使用的是什麼版本的碼頭和servlet的版本的'web.xml'聲明,但如果它的Servlet 2.5,你需要鑽嘴魚科2.0.x版本(目前最新的是2.0.6)。依賴關係是至少2.5的Servlet(由容器提供)和JSTL 1.2(可以或可以不通過容器中提供,相信碼頭沒有,但可能的Heroku做)。另請參閱需求清單http://javaserverfaces.java.net/nonav/rlnotes/2.0.6/releasenotes.html。 – BalusC

回答

2
java.lang.NullPointerException 
    at com.sun.faces.context.flash.ELFlash.getFlash(ELFlash.java:93) 
    at com.sun.faces.context.flash.ELFlash.getELFlash(ELFlash.java:124) 

我不承認ELFlash#getELFlash()方法作爲最近Mojarra實現的一部分。也許你正在使用一個很早的2.0.0實現,它有一個與此相關的錯誤。升級到最新版本應該可以解決這個問題。如果您faces-config.xml未正確申報符合JSF2規範


but the problem with annotations persists in Heroku

javax.el.PropertyNotFoundException: /login.xhtml @15,55 value="#{user.name}": Target Unreachable, identifier 'user' resolved to null 
    at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:100‌​) 
    at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(Html‌​BasicInputRenderer.java:95) 

JSF2註釋將失敗。請確保<faces-config>根聲明如下所示:

<faces-config 
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd" 
    version="2.0"> 

    <!-- config here --> 

</faces-config> 
+0

謝謝。問題不在於faces-config.xml。 但我解決了這個問題: http://musingsofaprogrammingaddict.blogspot.com/2009/12/running-jsf-2-on-embedded-jetty.html –

+1

使用嵌入式Web服務器時,我們意識到這個問題的。我希望JSF和其他框架能找到更好的方法來尋找註釋類。另一個解決方案是構建一個war文件並使用jetty-runner運行它。但它不太理想。 –

相關問題