2013-08-31 126 views
1

我需要使用JSF 2的WebSphere 7.0.0.13下運行的應用程序,我都遵循這樣的:的Websphere 7 JSF 2

http://www.manorrock.com/online/wiki/app/page/edit.html

***它說:

Even though Websphere 7 does not formally support JSF 2.0 you can get it to work in a degraded mode. Follow the steps below to get it to work on your version of Websphere 7. 
    Upgrade to at least version 7.0.0.13 
    Ship the Mojarra JAR files in your WEB-INF/lib directory 
    Set the WAR classloader to PARENT_LAST 
    Set the EAR classloader to PARENT_LAST and APPLICATION 
Note the degraded mode means you are NOT going to be able to use @Resource or any JPA annotations. If you think you need support for it contact your IBM representative. 
Note it will process @PostConstruct and @PreDestroy.*** 

我這樣做,但我得到這個錯誤,在日誌中:

[8/30/13 22:51:32:702 CDT] 0000000c webapp  E com.ibm.ws.webcontainer.webapp.WebApp notifyServletContextCreated SRVE0283E: Exception caught while initializing context: {0} 
           java.lang.LinkageError: loading constraint violation: loader "com/ibm/ws/classloader/[email protected]" previously initiated loading for a different type with name "javax/servlet/ServletContext" defined by loader "org/eclipse/osgi/internal/baseadaptor/[email protected]" 
    at com.sun.faces.config.WebConfiguration.getInstance(WebConfiguration.java:184) 
    at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:163) 
    at com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:1681) 
    at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinish(WebApp.java:374) 
    at com.ibm.ws.webcontainer.webapp.WebAppImpl.initialize(WebAppImpl.java:299) 
    at com.ibm.ws.webcontainer.webapp.WebGroupImpl.addWebApplication(WebGroupImpl.java:100 

而且誤差en我的網頁:

Error 404: javax.servlet.UnavailableException: SRVE0201E: Servlet [javax.faces.webapp.FacesServlet]: not a servlet class 

這是我的web.xml

<?xml version="1.0" encoding="UTF-8"?> 
<web-app id="WebApp_ID" version="2.5" 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-app_2_5.xsd"> 
    <display-name>testJSF2</display-name> 
    <welcome-file-list> 
     <welcome-file>index.jsp</welcome-file> 
    </welcome-file-list> 
    <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>*.faces</url-pattern> 
    </servlet-mapping> 
    <servlet-mapping> 
     <servlet-name>Faces Servlet</servlet-name> 
     <url-pattern>*.jsf</url-pattern> 
    </servlet-mapping> 
</web-app> 

我通過accesed:

..../testJSF2/index.faces 

如果我通過輸入:

..../testJSF2/index.jsp 

在頁面得到這樣的:

HTTP Error Code: 500 

Error Message: 

JSPG0049E: /index.jsp failed to compile : 
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/temp/wasccNode01/server4/testJSF2EAR/testJSF2.war/_index.java : 48 : The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory 
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/temp/wasccNode01/server4/testJSF2EAR/testJSF2.war/_index.java : 100 : The method handlePageException(Exception) in the type PageContext is not applicable for the arguments (Throwable) 
JSPG0091E: An error occurred at line: 20 in the file: /index.jsp 
JSPG0093E: Generated servlet error from file: /index.jsp 
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/temp/wasccNode01/server4/testJSF2EAR/testJSF2.war/_index.java : 119 : The method getELContext() is undefined for the type PageContext 
JSPG0091E: An error occurred at line: 21 in the file: /index.jsp 
JSPG0093E: Generated servlet error from file: /index.jsp 
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/temp/wasccNode01/server4/testJSF2EAR/testJSF2.war/_index.java : 144 : The method getELContext() is undefined for the type PageContext 

根本原因:

com.ibm.ws.jsp.JspCoreException: JSPG0049E: /index.jsp failed to compile : 
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/temp/wasccNode01/server4/testJSF2EAR/testJSF2.war/_index.java : 48 : The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory 
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/temp/wasccNode01/server4/testJSF2EAR/testJSF2.war/_index.java : 100 : The method handlePageException(Exception) in the type PageContext is not applicable for the arguments (Throwable) 
JSPG0091E: An error occurred at line: 20 in the file: /index.jsp 
JSPG0093E: Generated servlet error from file: /index.jsp 
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/temp/wasccNode01/server4/testJSF2EAR/testJSF2.war/_index.java : 119 : The method getELContext() is undefined for the type PageContext 
JSPG0091E: An error occurred at line: 21 in the file: /index.jsp 
JSPG0093E: Generated servlet error from file: /index.jsp 
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/temp/wasccNode01/server4/testJSF2EAR/testJSF2.war/_index.java : 144 : The method getELContext() is undefined for the type PageContext 
    at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.translateJsp(AbstractJSPExtensionServletWrapper.java:574) 
    at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper._checkForTranslation(AbstractJSPExtensionServletWrapper.java:441) 
    at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.checkForTranslation(AbstractJSPExtensionServletWrapper.java:299) 
    at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:149) 
    at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3826) 
    at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:276) 
    at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:931) 

感謝您幫助。

回答

0

我猜你不僅提供了JSF類,而且還提供了第二個實例/ api。

檢查您的WEB-INF/lib文件夾中是否有servlet-api或類似的東西。

因爲它不能加載ServletContext你會得到其他後續錯誤。也許甚至加載一個沒有JSF的簡單jsp就會失敗。

2

對於WebSphere 7,我已經按照另一篇文章:

http://wasbehindtheglass.blogspot.co.uk/2011/11/myfaces-20-and-websphere-application.html

我已經與以下罐子上的WebSphere(名稱並不重要,重要的內容)創建的共享庫:

manifest.jar
MyFaces的-API-2.0.7.jar
MyFaces的-IMPL-2.0.7.jar
共享記錄-1.1.1.jar
個 公共沼氣池-1.8.jar
公地集合-3.2.jar
公地編解碼器1.3.jar
公地的BeanUtils-1.8.3.jar
\ IBM \ SDP \運行時間\ base_v7 \ optionalLibraries \ IBM \ JSFProviders \ WebSphere-MyFaces20-annotation-provider.jar

您需要提供絕對路徑。 WebSphere-MyFaces20-annotation-provider.jar應該在您的WebSphere安裝中。 manifest.jar是隻包含以下META-INF/MANIFEST的jar。MF:

Manifest-Version: 1.0 
Extension-Name: org/apache/myfaces 
Specification-Title: MyFaces 2.0.7 shared lib 
Specification-Version: 1.0 
Specification-Vendor: apache.org 
Implementation-Version: 1.0 

最後一件事就是修改你的pom.xml創建引用共享庫的清單條目:

<manifestEntries> 
<Extension-List>myfaces</Extension-List> 
<myfaces-Extension-Name>org/apache/myfaces</myfaces-Extension-Name> 
<myfaces-Specification-Version>1.0</myfaces-Specification-Version> 
</manifestEntries> 

部署後,如果同時共享庫和清單配置正確地,綁定是自動創建的。

0

我想這一點,並且它是工作,這裏只是把對未來的問題

這個問題發生,因爲我們添加的servlet-API-2.5.jar在項目的lib所以當我們刪除它的替代解決方案工作。 所以這裏最後一步得到這個工作 1-設置父類最後的應用程序和模塊的類加載策略。 2- servlet的API-2.5的.jar不添加到,項目的lib

從這裏

https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014541986

0

Ç抽放:\ Apache的Tomcat的8.0.3 \的webapps \ kumar-應用\ WEB-INF \ lib中\ servlet的API-2.3.jar

C:\ Apache的Tomcat的8.0.3 \ LIB \ servlet的api.jar文件

我上面jar文件版本不匹配,我從C:\ apache-tomcat-8.0.3 \ webapps \ kumar-app \ WEB-INF \ lib \ servlet-api-2.3.jar和我的應用中刪除了jar正確運行。