Java JSF 2.0 可以与 Websphere 应用服务器版本 7.x 一起使用吗
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1718934/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can JSF 2.0 be used with Websphere application server version 7.x
提问by Dm.
Can JSF 2.0 be used with WebSphere Application Server version 7.x?
JSF 2.0 可以与 WebSphere Application Server 7.x 版一起使用吗?
If so, how?
如果是这样,如何?
回答by Gene De Lisa
Websphere ships with JSF 1.2.something and it loads that by default. To use a different JSF library (or any other library that WS provides such as commons-logging) you need to change the way the classloader prioritizes locations. They call it 'parent last" meaning load your libs then the WS versions.
Websphere 附带 JSF 1.2.something 并默认加载它。要使用不同的 JSF 库(或 WS 提供的任何其他库,例如 commons-logging),您需要更改类加载器确定位置优先级的方式。他们称它为“最后一个父级”,意思是先加载你的库,然后是 WS 版本。
回答by RDean
The WebSphere Infocenterindicates that the right way to change to an alternative JSF implementation is to create a WebSphere Shared Library with the isolated classloader option enabled.
在WebSphere信息中心表示,要改变一种替代JSF实现正确的方法是创建一个WebSphere共享库与隔离的类加载器选项启用。
Any modules that need JSF 2 would be associated with the new shared library, and then the application would start with JSF 2 instead of JSF 1.2.
任何需要 JSF 2 的模块都将与新的共享库相关联,然后应用程序将从 JSF 2 而不是 JSF 1.2 开始。
It is also necessary to have fix pack 7.0.0.19 or later installed.
回答by setzamora
I've been struggling to solve this for days. Here's how I solved it.
这几天我一直在努力解决这个问题。这是我解决它的方法。
Use the following library: javax.faces-2.1.7.jar
使用以下库:javax.faces-2.1.7.jar
If you are on PrimeFaces 3.1: primefaces-3.1.1.jar
如果您使用的是 PrimeFaces 3.1:primefaces-3.1.1.jar
Application Server instance: Class Loading - Parent Last
应用程序服务器实例:类加载 - 父级最后
Enterprise Application instance (war Module): Class Loading - Parent Last
企业应用实例(war 模块):类加载 - 父级
Make sure to remove all Servlet Container libraries such as those needed by Tomcat.
确保删除所有 Servlet 容器库,例如 Tomcat 所需的库。
回答by iyildiz
Step by step setting MyFaces 2.0 on WebSphere Application Server v7 as shared library as IBM recommends: http://wasbehindtheglass.blogspot.co.uk/
按照 IBM 的建议,逐步将 WebSphere Application Server v7 上的 MyFaces 2.0 设置为共享库:http: //wasbehindtheglass.blogspot.co.uk/
I have applied similar steps for Majorra/JSF 2.0.4 and created a shared library using only jsf-api.jar and jsf-impl.jar. As @Ian McLaird has told WAS 7.0.0.19 and JSF 2.0.4 are required. JSF 2.1.x requires Servlet 3 and is not supported by WAS7
我对 Majorra/JSF 2.0.4 应用了类似的步骤,并仅使用 jsf-api.jar 和 jsf-impl.jar 创建了一个共享库。正如@Ian McLaird 所说,需要 WAS 7.0.0.19 和 JSF 2.0.4。JSF 2.1.x 需要 Servlet 3 并且不受 WAS7 支持
回答by Mikolaj
My Experience:
我的经验:
-> WAS 7.0.0.11 on Windows
-> 在 Windows 上是 7.0.0.11
-> javax.faces-2.0.11.jar in WEB-INF/lib of my War application
-> 我的 War 应用程序的 WEB-INF/lib 中的 javax.faces-2.0.11.jar
-> WAS Shared librairies with javax.faces-2.0.11.jar with Isolated Class Loader
-> 使用 javax.faces-2.0.11.jar 与隔离类加载器共享库
-> WAS Shared librairies associated with my War App
-> 与我的 War 应用程序相关的 WAS 共享库
-> No change on Class Loader for instance and application (PARENT_FIRST)
-> 实例和应用程序的类加载器没有变化(PARENT_FIRST)
With this conf (above) the application works fine with JSF 2.0 on WAS 7. if i delete the javax.faces-2.0.11.jar from my War app, it doesn't works.
有了这个 conf(上面),应用程序可以在 WAS 7 上与 JSF 2.0 一起正常工作。如果我从我的 War 应用程序中删除 javax.faces-2.0.11.jar,它就不起作用。
回答by AmitPathak83
Following worked for me
以下为我工作
- Create a shared library and put your JSF 2.0 jars in it.
- Also add EL 2.2 API and EL-Impl 2.2 jars as well since JSF 2.0 implicitly needs this.
- Add this library to your application and make classloader preference as PARENT_LAST.
- 创建一个共享库并将您的 JSF 2.0 jar 放入其中。
- 还要添加 EL 2.2 API 和 EL-Impl 2.2 jar,因为 JSF 2.0 隐含地需要它。
- 将此库添加到您的应用程序并将类加载器首选项设为 PARENT_LAST。
Change web.xml as following
更改 web.xml 如下
<context-param>
<param-name>com.sun.faces.expressionFactory</param-name>
<param-value>com.sun.el.ExpressionFactoryImpl</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
Thats it .
就是这样 。
回答by DuSant
Hi I could run my website using this libraries
嗨,我可以使用这个库运行我的网站
Configuring in web.xml of my project
在我的项目的 web.xml 中配置
<context-param>
<param-name>com.sun.faces.expressionFactory</param-name>
<param-value>com.sun.el.ExpressionFactoryImpl</param-value>
</context-param>
Configuring in websphere to load my libraries (Parent Last)
在 websphere 中配置以加载我的库(父级)
Regards
问候
回答by Laurent
Thank you guys!
谢谢你们!
It worked with a newer version of javax.faces. See the maven dependencies:
它适用于较新版本的 javax.faces。查看maven依赖:
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>2.1.29-08</version>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>com.sun.el</groupId>
<artifactId>el-impl</artifactId>
<version>2.2</version>
</dependency>
Don't forget to add the following in your web.xml:
不要忘记在 web.xml 中添加以下内容:
<context-param>
<param-name>com.sun.faces.expressionFactory</param-name>
<param-value>com.sun.el.ExpressionFactoryImpl</param-value>
</context-param>
And finally change the WebSphere class loader order of the application and the module to the (parent last)settings: https://www.ibm.com/support/knowledgecenter/SSAW57_7.0.0/com.ibm.websphere.nd.doc/info/ae/ae/urun_rclassloader_inst.html
最后将应用程序和模块的 WebSphere 类加载器顺序更改为(父级最后)设置:https: //www.ibm.com/support/knowledgecenter/SSAW57_7.0.0/com.ibm.websphere.nd.doc/ info/ae/ae/urun_rclassloader_inst.html
Regards
问候