2012-08-27 87 views
2

我在Eclipse Juno中使用WebSphere Application Server V8.5 Liberty Profile。 我配置了我的AppServer(server.xml)並添加了jsp-2.2,jsf2.0,localConnector-1.0和servlet-3.0 Feature。JSF不適用於WebSphere Liberty Profile

當我部署我的項目並在瀏覽器中打開JSP頁面時,一切正常。 但是,當我想開一個JSF頁,然後我得到以下異常:

[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 

是Eclipse生成我的web.xml和看起來像:

<?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> 

那麼是什麼問題這裏?

回答

5

看起來,您可能既啓用了jsf-2.0功能,也在應用程序中捆綁了自己的MyFaces副本。

如果您希望使用作爲Liberty一部分提供的jsf-2.0實現,我會建議從您的應用程序中刪除MyFaces jars,並刪除集成環境中不需要的StartupServletContextListener。

如果您不想使用捆綁在應用程序中的jsf實現,則可以從server.xml中刪除jsf-2.0功能。

+0

太好了,這解決了我的問題! – veote

0

從您的應用程序中刪除jsf/myfaces lib並更改服務器配置。轉到功能管理器並添加jsf 2.0/jsf2.2。

相關問題