1

我需要将 JSF 2 用于在 Websphere 7.0.0.13 下运行的应用程序,我遵循了这个:

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/CompoundClassLoader@31c031c" previously initiated loading for a different type with name "javax/servlet/ServletContext" defined by loader "org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader@66656665"
    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

我的页面上的错误:

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>

我通过以下方式访问:

..../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)

谢谢你的帮助。

4

4 回答 4

2

对于 WebSphere 7,我关注了另一篇文章:

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

我在 WebSphere 上创建了共享库(名称不重要,只有内容),其中包含以下 jar:

manifest.jar
myfaces-api-2.0.7.jar
myfaces-impl-2.0.7.jar
commons-logging-1.1.1.jar
commons-digester-1.8.jar
commons-collections-3.2.jar
commons-codec-1.3。 jar
commons-beanutils-1.8.3.jar
\IBM\SDP\runtimes\base_v7\optionalLibraries\IBM\JSFProviders\WebSphere-MyFaces20-annotation-provider.jar

您需要提供绝对路径。WebSphere-MyFaces20-annotation-provider.jar 应该在您的 WebSphere 安装中。manifest.jar 是仅包含以下 META-INF/MANIFEST.MF 的 jar:

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>

部署后,如果共享库和清单都配置正确,则自动创建绑定。

于 2013-09-09T17:35:01.060 回答
0

C:\apache-tomcat-8.0.3\webapps\kumar-app\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,我的应用程序运行正常。

于 2015-02-24T13:26:10.943 回答
0

我试过了,它正在工作,只是在这里为未来的问题提供一个替代解决方案

发生这个问题是因为我们在项目库中添加了 servlet-api-2.5.jar,所以当我们删除它时它可以工作。所以这里是完成这项工作的最后一步 1-在应用程序和模块的类加载策略中最后设置父级。2-不要将 servlet-api-2.5 .jar 添加到项目库中

取自这里

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

于 2014-11-15T20:41:08.200 回答
0

我猜您不仅提供了 JSF 类,还提供了第二个实例/api。

检查您的WEB-INF/lib文件夹中是否有 servlet-api 或类似的东西。

由于它无法加载,ServletContext您会收到其他后续错误。甚至可能加载一个没有 JSF 的简单 jsp 也会失败。

于 2013-08-31T23:27:32.207 回答