获取 - jsf2的错误"...工厂javax.faces.context.FacesContextFactory的备份".在grails插件项目中

WIL*_*MAN 3 grails plugins jsf-2

在开发模式下运行grails 2.01和tomcat(正常的STS开发人员下载)

我试图运行jsf插件,但它不会在grails 2中工作

所以对于我来说,我试图构建我自己的本地插件,将其构建为本机v2插件,并在途中了解插件项目.已经解构(慢慢)grails jsf2插件并一点一点地重建它并随着我去学习

我的问题如下 - 我在本地构建了我的插件 - 称为'wwjsf'

我已经完成了doWithWebDescriptor闭包 - 但是当我运行插件时我得到一个错误 - 并且服务器不会呈现.xhtml文件 - 任何此类请求都会出现同样的错误.

我已将最新的mojarra jsf 2.1.7 api/impl文件包含到我的项目构建路径中 - 这是在grails 2.01中嵌入的默认tomcat的错误

Message: Could not find backup for factory javax.faces.context.FacesContextFactory.
Line | Method
->> 1008 | getFactory in javax.faces.FactoryFinder$FactoryManager
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|    343 | getFactory in javax.faces.FactoryFinder
|    302 | init . . . in javax.faces.webapp.FacesServlet
|    303 | innerRun   in java.util.concurrent.FutureTask$Sync
|    138 | run . . .  in java.util.concurrent.FutureTask
|    886 | runTask    in java.util.concurrent.ThreadPoolExecutor$Worker
|    908 | run . . .  in     ''
^    662 | run        in java.lang.Thread
| Error 2012-04-04 18:32:55,748 [pool-6-thread-1] ERROR [localhost].[/wwjsf]  - Servlet    /wwjsf threw load() exception
Message: Could not find backup for factory javax.faces.context.FacesContextFactory.
Line | Method
->> 1008 | getFactory in javax.faces.FactoryFinder$FactoryManager
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|    343 | getFactory in javax.faces.FactoryFinder
|    302 | init . . . in javax.faces.webapp.FacesServlet
|    303 | innerRun   in java.util.concurrent.FutureTask$Sync
|    138 | run . . .  in java.util.concurrent.FutureTask
|    886 | runTask    in java.util.concurrent.ThreadPoolExecutor$Worker
|    908 | run . . .  in     ''
^    662 | run        in java.lang.Thread
| Server running. Browse to http://localhost:8080/wwjsf
Run Code Online (Sandbox Code Playgroud)

我已经在闭包中完成了web.xml的转储,以便查看.我在谷歌上查找错误,它说你必须设置facesConfigureListener - 我有,我已经检查了xml中的faces服务器元素,我觉得它看起来不错.

另外我在WEB-INF下面放了一个空的faces-config.xml(我会担心如何在以后使用该插件的项目中创建它),并且正如一些谷歌警告说我必须拥有WEB-INF/lib目录中的jsf文件 - 我手动创建了/ lib并将我的jsf 2.1.7 api/impl jar复制到其中 - 带和括号

如何摆脱嵌入式tomcat服务器中的此错误?有点卡住了,直到我能通过这个问题

非常感谢dev论坛上的任何人的帮助(道歉第一部分不想格式化,即使我在每行之前放了四个空格......)最终web.xml配置看起来像:

 <?xml version="1.0" encoding="UTF-8"?>
 <web-app xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org /2001/XMLSchema-instance" 
    metadata-complete="true" version="2.5" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
   <display-name>/wwjsf-development-null</display-name>
   <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/applicationContext.xml</param-value>
   </context-param>
   <context-param>
     <param-name>com.sun.faces.validateXml</param-name>
     <param-value>false</param-value>
   </context-param>
   <context-param>
      <param-name>com.sun.faces.verifyObjects</param-name>
      <param-value>false</param-value>
   </context-param>
   <context-param>
      <param-name>javax.faces.application.CONFIG_FILES</param-name>
      <param-value>C:\Users\802518659\Documents\grails-workspace\wwjsf\web-app\WEB-INF\faces-config.xml</param-value>
   </context-param>
   <context-param>
      <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
      <param-value>server</param-value>
   </context-param>
   <context-param>
      <param-name>javax.faces.FACELETS_RESOURCE_RESOLVER</param-name>
      <param-value>com.softwood.grails.jsf.facelets.GrailsResourceResolver</param-value>
   </context-param>
   <context-param>
      <param-name>javax.faces.PROJECT_STAGE</param-name>
      <param-value>Production</param-value>
   </context-param>
   <context-param>
      <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
      <param-value>.xhtml</param-value>
   </context-param>
   <context-param>
      <param-name>javax.faces.REFRESH_PERIOD</param-name>
      <param-value>0</param-value>
   </context-param>
   <context-param>
      <param-name>webAppRootKey</param-name>
      <param-value>wwjsf-development-null</param-value>
   </context-param>
   <filter>
     <filter-name>sitemesh</filter-name>
     <filter-class>org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter</filter-class>
   </filter>
   <filter>
     <filter-name>charEncodingFilter</filter-name>
     <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
     <init-param>
        <param-name>targetBeanName</param-name>
        <param-value>characterEncodingFilter</param-value>
     </init-param>
     <init-param>
        <param-name>targetFilterLifecycle</param-name>
        <param-value>true</param-value>
     </init-param>
   </filter>
   <filter>
      <filter-name>urlMapping</filter-name>
      <filter-class>org.codehaus.groovy.grails.web.mapping.filter.UrlMappingsFilter</filter-class>
   </filter>
   <filter>
     <filter-name>hiddenHttpMethod</filter-name>
     <filter-class>org.codehaus.groovy.grails.web.filters.HiddenHttpMethodFilter</filter-class>
   </filter>
   <filter>
      <filter-name>grailsWebRequest</filter-name>
      <filter-class>org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequestFilter</filter-class>
   </filter>
   <filter-mapping>
      <filter-name>charEncodingFilter</filter-name>
      <url-pattern>/*</url-pattern>
   </filter-mapping>
   <filter-mapping>
      <filter-name>hiddenHttpMethod</filter-name>
      <url-pattern>/*</url-pattern>
     <dispatcher>FORWARD</dispatcher>
     <dispatcher>REQUEST</dispatcher>
   </filter-mapping>
   <filter-mapping>
      <filter-name>grailsWebRequest</filter-name>
      <url-pattern>/*</url-pattern>
      <dispatcher>FORWARD</dispatcher>
      <dispatcher>REQUEST</dispatcher>
      <dispatcher>ERROR</dispatcher>
   </filter-mapping>
   <filter-mapping>
      <filter-name>sitemesh</filter-name>
       <url-pattern>/*</url-pattern>
       <dispatcher>REQUEST</dispatcher>
       <dispatcher>ERROR</dispatcher>
   </filter-mapping>
   <filter-mapping>
      <filter-name>urlMapping</filter-name>
      <url-pattern>/*</url-pattern>
      <dispatcher>FORWARD</dispatcher>
      <dispatcher>REQUEST</dispatcher>
   </filter-mapping>
   <listener>
      <listener-class>org.codehaus.groovy.grails.plugins.log4j.web.util.Log4jConfigListener</listener-class>
   </listener>
   <listener>
      <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
    </listener>
    <listener>
        <listener-class>org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener</listener-class>
    </listener>
  <servlet>
   <servlet-name>H2Console</servlet-name>
   <servlet-class>org.h2.server.web.WebServlet</servlet-class>
   <init-param>
    <param-name>-webAllowOthers</param-name>
    <param-value>true</param-value>
   </init-param>
   <load-on-startup>2</load-on-startup>
  </servlet>
  <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>H2Console</servlet-name>
    <url-pattern>/dbconsole/*</url-pattern>
    </servlet-mapping>
  <servlet-mapping>
     <servlet-name>Faces Servlet</servlet-name>
     <url-pattern>*.xhtml</url-pattern>
  </servlet-mapping>

  <servlet>
    <servlet-name>grails</servlet-name>
    <servlet-class>org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet>
    <servlet-name>gsp</servlet-name>
    <servlet-class>org.codehaus.groovy.grails.web.pages.GroovyPagesServlet</servlet-class>
    <init-param>
    <description>
            Allows developers to view the intermediate source code, when they pass
            a spillGroovy argument in the URL.
            </description>
    <param-name>showSource</param-name>
    <param-value>1</param-value>
    </init-param>
  </servlet>
  <servlet>
     <servlet-name>grails-errorhandler</servlet-name>
     <servlet-class>org.codehaus.groovy.grails.web.servlet.ErrorHandlingServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>gsp</servlet-name>
    <url-pattern>*.gsp</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
   <servlet-name>grails-errorhandler</servlet-name>
   <url-pattern>/grails-errorhandler</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
     <servlet-name>grails</servlet-name>
     <url-pattern>*.dispatch</url-pattern>
  </servlet-mapping>
  <welcome-file-list>

    <welcome-file>index.html</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>index.gsp</welcome-file>
  </welcome-file-list>
  <error-page>
    <error-code>500</error-code>
    <location>/grails-errorhandler</location>
 </error-page>
 <jsp-config>
    <taglib>
        <taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
        <taglib-location>/WEB-INF/tld/c.tld</taglib-location>
    </taglib>
       <taglib>
           <taglib-uri>http://java.sun.com/jsp/jstl/fmt</taglib-uri>
           <taglib-location>/WEB-INF/tld/fmt.tld</taglib-location>
        </taglib>
        <taglib>
            <taglib-uri>http://www.springframework.org/tags</taglib-uri>
            <taglib-location>/WEB-INF/tld/spring.tld</taglib-location>
        </taglib>
        <taglib>
            <taglib-uri>http://grails.codehaus.org/tags</taglib-uri>
            <taglib-location>/WEB-INF/tld/grails.tld</taglib-location>
        </taglib>
    </jsp-config>
 </web-app>
Run Code Online (Sandbox Code Playgroud)

jos*_*hua 10

当我遇到这个错误时(我使用maven和嵌入式jetty以及spring和jsf2),我在web.xml上添加了这个

 <listener>
        <listener-class>com.sun.faces.config.ConfigureListener</listener-class> 
    </listener>
Run Code Online (Sandbox Code Playgroud)

错误消失了.