繁体   English   中英

具有JSF 2的Websphere 7

[英]Websphere 7 with JSF 2

对于在Websphere 7.0.0.13下运行的应用程序,我需要使用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/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)

感谢您的帮助。

对于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
共享记录-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-注解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>

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

我想您不仅要提供JSF类,而且还要提供第二个实例/ api。

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

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

我试过了,而且行得通,只是在这里为以后的问题提供了替代解决方案

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

从这里拿走

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

C:\\ Apache的Tomcat的8.0.3 \\的webapps \\库马尔 - 应用\\ 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,我的应用程序正常运行。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM