0

我无法在 Winstone 服务器上发布 JSF2 应用程序。

服务器配置良好,当我删除

<load-on-startup>1</load-on-startup>

从web.xml,它正常启动:

在此处输入图像描述

但是当我尝试启动 indew.xhtml 时,服务器报告:

在此处输入图像描述

我的web.xml的一部分:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
         xmlns="http://java.sun.com/xml/ns/javaee" 
         xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
         id="WebApp_ID" version="2.5">
  <display-name>PIA</display-name>
  <session-config>
    <session-timeout>60</session-timeout>
  </session-config>
  <welcome-file-list>
    <welcome-file>index.xhtml</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>*.xhtml</url-pattern>
  </servlet-mapping>

  <context-param>
    <description>State saving method: 'client' or 'server'.</description>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
  </context-param>
  <context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>resources.application</param-value>
  </context-param>
  <context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.xhtml</param-value>
  </context-param>
</web-app>

更新:我试过winstone 1.0.0.jar了,它报告了这个:

在此处输入图像描述

但是我有slf4j-api-1.6.4.jar并且slf4j-log4j12-1.6.4.jar在我的 WEB-INF\lib 文件夹中......应该是哪里出了问题?

4

1 回答 1

1

将此添加到您的web.xml以显式注册应该配置 JSF 工厂的侦听器。

<listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>

另一种可能的解决方案是<load-on-startup>从中删除FacesServlet,但我从未使用过 Winstone,因此我无法保证这是否可以在该服务器上运行。

This workaround is usually not mandatory in decent servers, but in poor servers it is. For more background information, see also could not find Factory: javax.faces.context.FacesContextFactory.


Update as per the comments, after adding the listener the exception disappeared, but now a Error instantiating listener class: com.sun.faces.config.ConfigureListener appears without any stacktrace. The swallowing of the stacktrace seems to be a Winstone bug which was fixed in 1.0.0. Give it a try, it should now show the real cause of the problem.


根据问题更新更新 2,真正的原因似乎是NoClassDefFoundErroron org.slf4j.loggerFactory。然而,Mojarra 并没有以任何方式使用它。堆栈跟踪还表明这是在加载任何侦听器之前发生的。换句话说,这可能是一个与 Winstone 有关的不同问题。显然 Winstone本身需要那个库。将其添加到 Winstone 的运行时类路径而不是/WEB-INF/lib.

于 2011-12-09T15:24:09.170 回答