gpt4 book ai didi

java - JSF 不在 WebSphere Liberty Profile 上工作

转载 作者:行者123 更新时间:2023-11-30 05:52:01 27 4
gpt4 key购买 nike

我在 Eclipse Juno 中使用 WebSphere Application Server V8.5 Liberty Profile。我配置了我的 AppServer (server.xml) 并添加了 jsp-2.2、jsf2.0、localConnector-1.0 和 servlet-3.0 功能。

当我部署我的项目并在我的浏览器中打开一个 JSP 页面时,一切都很顺利。但是当我想打开一个 JSF-Page 时,我得到以下异常:

[ERROR   ] An error occured while initializing MyFaces: org.apache.myfaces.spi.impl.DefaultFacesConfigurationMergerFactory cannot be cast to org.apache.myfaces.spi.FacesConfigurationMergerFactory
[ERROR ] Uncaught.init.exception.thrown.by.servlet
[ERROR ] SRVE0266E: Error occured while initializing servlets: javax.servlet.ServletException: SRVE0207E: Uncaught initialization exception created by servlet
at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:382)
at com.ibm.ws.webcontainer.osgi.servlet.ServletWrapper.init(ServletWrapper.java:83)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.loadOnStartupCheck(ServletWrapper.java:1353)
at com.ibm.ws.webcontainer.webapp.WebApp.doLoadOnStartupActions(WebApp.java:862)
at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinally(WebApp.java:831)
at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:753)
at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:5694)
at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.createRunnableHandler(DynamicVirtualHost.java:220)
at com.ibm.ws.http.internal.VirtualHostImpl.discriminate(VirtualHostImpl.java:165)
at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.ready(HttpDispatcherLink.java:157)
at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:444)
at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleNewRequest(HttpInboundLink.java:378)
at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.processRequest(HttpInboundLink.java:278)
at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.ready(HttpInboundLink.java:249)
at com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:174)
at com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:83)
at com.ibm.ws.tcpchannel.internal.WorkQueueManager.requestComplete(WorkQueueManager.java:502)
at com.ibm.ws.tcpchannel.internal.WorkQueueManager.attemptIO(WorkQueueManager.java:550)
at com.ibm.ws.tcpchannel.internal.WorkQueueManager.workerRun(WorkQueueManager.java:899)
at com.ibm.ws.tcpchannel.internal.WorkQueueManager$Worker.run(WorkQueueManager.java:981)
at com.ibm.ws.threading.internal.Worker.executeWork(Worker.java:398)
at com.ibm.ws.threading.internal.Worker.run(Worker.java:380)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalStateException: No Factories configured for this Application. This happens if the faces-initialization does not work at all - make sure that you properly include all configuration settings necessary for a basic faces application and that all the necessary libs are included. Also check the logging output of your web application and your container for any exceptions!
If you did that and find nothing, the mistake might be due to the fact that you use some special web-containers which do not support registering context-listeners via TLD files and a context listener is not setup in your web.xml.
A typical config looks like this;
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>

at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:172)
at javax.faces.webapp.FacesServlet.init(FacesServlet.java:112)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:320)
... 22 more

我的 web.xml 是由 eclipse 生成的,看起来像:

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="3.0" 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_3_0.xsd">
<display-name>WAS-Liberty-Test</display-name>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<context-param>
<description>
State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<description>

This parameter tells MyFaces if javascript code should be allowed in
the rendered HTML output.
If javascript is allowed, command_link anchors will have javascript code
that submits the corresponding form.
If javascript is not allowed, the state saving info and nested parameters
will be added as url parameters.
Default is 'true'</description>
<param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>

If true, rendered HTML code will be formatted, so that it is 'human-readable'
i.e. additional line separators and whitespace will be written, that do not
influence the HTML code.
Default is 'true'</description>
<param-name>org.apache.myfaces.PRETTY_HTML</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<description>

If true, a javascript function will be rendered that is able to restore the
former vertical scroll on every request. Convenient feature if you have pages
with long lists and you do not want the browser page to always jump to the top
if you trigger a link or button action that stays on the same page.
Default is 'false'
</description>
<param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
<param-value>true</param-value>
</context-param>
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<enabled>true</enabled>
<async-supported>false</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>
/faces/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>

那么这里有什么问题呢?

最佳答案

看来您可能既启用了 jsf-2.0 功能,又在您的应用程序中捆绑了您自己的 MyFaces 副本。

如果您希望使用作为 Liberty 的一部分提供的 jsf-2.0 实现,我建议您从您的应用程序中删除 MyFaces jar,并删除集成环境中不需要的 StartupServletContextListener。

如果您希望使用捆绑在应用程序中的 jsf 实现,则可以从 server.xml 中删除 jsf-2.0 功能。

关于java - JSF 不在 WebSphere Liberty Profile 上工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12138856/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com