将JSF更新为2.1,Richfaces更新为4.3.7

时间:2015-12-27 16:22:05

标签: maven jsf-2 richfaces prettyfaces

更新时

  • jsf从1.2到2.1
  • richfaces from 3.3.3 to 4.3.7.Final

关注this link

我遇到了一些奇怪的异常

java.lang.NullPointerException
com.ocpsoft.pretty.faces.application.PrettyNavigationHandler.processFacesNavigation(PrettyNavigationHandler.java:58)
com.ocpsoft.pretty.faces.application.PrettyNavigationHandler.handleNavigation(PrettyNavigationHandler.java:44)
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:130)
javax.faces.component.UICommand.broadcast(UICommand.java:315)
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
ua.com.winforce.online.site.http.filter.LocaleFilter.doFilter(LocaleFilter.java:65)

在login.jspx页面上提交简单表单后出现

<h:form>
<div class="form-group">
    <label for="rLogin"><h:outputText value="#{localeController.locale.registr.email}" escape="false"/></label>
    <h:inputText id="rLogin"  value="#{playerRegistration.login}" />
</div>
<div class="form-group">
    <label for="rPassword"><h:outputText value="#{localeController.locale.registr.password}" escape="false"/></label>
    <h:inputSecret value="#{playerRegistration.password}"/>
</div>
    <h:commandButton value="#{localeController.locale.mainMsg.registration}" action="#{playerRegistration.doRegistration}" />

LocaleFilter照常工作。

更新后我离开.jspx页面格式。

我认为配置有问题,但找不到原因。

main pom.xml:

<properties>
    <targetJdk>1.6</targetJdk>
    <spring.version>4.0.5.RELEASE</spring.version>
    <spring.security.version>3.2.4.RELEASE</spring.security.version>
    <hibernate.version>4.2.16.Final</hibernate.version>
    <richfaces.version>4.3.7.Final</richfaces.version>
</properties>

<dependencyManagement>
    <dependencies>
        <!-- Utils -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.14</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.7</version>
        </dependency>

        <!-- Servlets / JSP / JSTL -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <type>jar</type>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.1</version>
            <type>jar</type>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>

         <!-- RichFaces libraries -->
        <dependency>
      <groupId>org.richfaces</groupId>
      <artifactId>richfaces-bom</artifactId>
      <version>${richfaces.version}</version>
      <scope>import</scope>
      <type>pom</type>
    </dependency>

    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
      <groupId>com.sun.faces</groupId>
      <artifactId>jsf-api</artifactId>
    </dependency>
    <dependency>
      <groupId>com.sun.faces</groupId>
      <artifactId>jsf-impl</artifactId>
    </dependency>

    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>wsdl4j</groupId>
        <artifactId>wsdl4j</artifactId>
        <version>1.6.1</version>
    </dependency>
    <dependency>
        <groupId>org.richfaces.core</groupId>
        <artifactId>richfaces-core-impl</artifactId>
      </dependency>
      <dependency>
        <groupId>org.richfaces.ui</groupId>
        <artifactId>richfaces-components-ui</artifactId>
      </dependency>
</dependencies>

的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"
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
     http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
     version="3.0">
<mime-mapping>
    <extension>jspx</extension>
    <mime-type>application/xml</mime-type>
</mime-mapping>

<context-param>
    <param-name>javax.faces.application.CONFIG_FILES</param-name>
    <param-value>/WEB-INF/faces-config.xml</param-value>
</context-param>

<context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.jspx</param-value>
</context-param>    
<context-param>
    <param-name>javax.faces.FACELETS_SUFFIX</param-name>
    <param-value>.jspx</param-value>
</context-param>    
<context-param>
    <param-name>javax.faces.FACELETS_VIEW_MAPPINGS</param-name>
    <param-value>*.jspx</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>facelets.DEVELOPMENT</param-name>
    <param-value>false</param-value>
</context-param>

<context-param>
        <param-name>com.sun.faces.enableRestoreView11Compatibility</param-name>
        <param-value>false</param-value>
</context-param>

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        /WEB-INF/applicationContext-site-dao.xml
        /WEB-INF/applicationContext-site-security.xml
    </param-value>
</context-param>

<context-param>
    <param-name>com.sun.faces.sendPoweredByHeader</param-name>
    <param-value>false</param-value>
</context-param>

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
    <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<listener>
    <listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</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>
</servlet>

<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.html</url-pattern>
</servlet-mapping>

faces-config.xml标题:

<faces-config version="2.1" 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-facesconfig_2_1.xsd">
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
<locale-config>
        <default-locale>ru</default-locale>
        <supported-locale>ru</supported-locale>
        <supported-locale>en</supported-locale>
    </locale-config>

以下是项目中使用的库:

  • 组织/ graylog2 / gelfj / 0.9.1-SNAPSHOT / gelfj-0.9.1-SNAPSHOT.jar
  • COM / googlecode上/ JSON-简单/ JSON-简单/ 1.1 / JSON-简单-1.1.jar
  • 公地池/公地池/ 1.5.2 /公地池1.5.2.jar
  • jcraft / jcraft / 1 / jcraft-1.jar
  • jazzlib / jazzlib / 1.07 / jazzlib-1.07.jar
  • 净/ SF / JSON-LIB / JSON-LIB / 2.2.3 / JSON-LIB-2.2.3-jdk15.jar
  • 净/ SF / ezmorph / ezmorph / 1.0.6 / ezmorph-1.0.6.jar
  • 的javax /邮件/邮件/ 1.4.1 /邮件1.4.1.jar
  • 的javax /激活/激活/ 1.1 /活化-1.1.jar
  • license4j运行时/ license4j运行时/ 3.1 / license4j运行时-3.1.jar
  • jdbcappender / jdbcappender / 2.1.01 / jdbcappender-2.1.01.jar
  • 的log4j / log4j的/ 1.2.14 / log4j的-1.2.14.jar
  • 组织/ SLF4J / SLF4J-log4j12 / 1.7.7 / SLF4J-log4j12-1.7.7.jar
  • 公地琅/公地琅/ 2.4 /公地琅2.4.jar
  • 公地IO /公地IO / 1.4 /公地-IO-1.4.jar
  • 公地集合/公地集合/ 3.2 /公地集合-3.2.jar
  • 公地DBCP /公地DBCP / 1.2.1 /公地DBCP-1.2.1.jar
  • XML的API / XML的API / 1.0.b2 / XML的API-1.0.b2.jar
  • 的xerces / xercesImpl / 2.9.1 / xercesImpl-2.9.1.jar
  • 公地发现/公地发现/ 0.4 /公地发现-0.4.jar
  • 共享记录/共享记录/ 1.0.4 /共享记录-1.0.4.jar
  • 的javax / servlet的/ JSTL / 1.2 / JSTL-1.2.jar
  • COM /太阳/小面/ JSF的小面/ 1.1.15 / JSF的小面-1.1.15.jar
  • 的AspectJ / aspectjrt / 1.5.3 / aspectjrt-1.5.3.jar
  • 的AspectJ / aspectjweaver / 1.5.3 / aspectjweaver-1.5.3.jar
  • jfree / jcommon / 1.0.12 / jcommon-1.0.12.jar
  • 组织/ springframework的/弹簧的Web / 4.0.5.RELEASE /弹簧网络4.0.5.RELEASE.jar
  • 组织/ springframework的/弹簧的AOP / 4.0.5.RELEASE /弹簧AOP-4.0.5.RELEASE.jar
  • 组织/ springframework的/弹簧JDBC / 4.0.5.RELEASE /弹簧JDBC-4.0.5.RELEASE.jar
  • 组织/ springframework的/弹簧-TX / 4.0.5.RELEASE /弹簧-TX-4.0.5.RELEASE.jar
  • 组织/ springframework的/弹簧ORM / 4.0.5.RELEASE /弹簧ORM-4.0.5.RELEASE.jar
  • 组织/ springframework的/弹簧支撑/ 2.0.8 /弹簧支撑2.0.8.jar
  • aopalliance / aopalliance / 1.0 / aopalliance-1.0.jar
  • 组织/ springframework的/安全/弹簧安全核/ 3.2.4.RELEASE /弹簧安全核心3.2.4.RELEASE.jar
  • 组织/ springframework的/弹簧表达/ 3.2.8.RELEASE /弹簧表达-3.2.8.RELEASE.jar
  • 组织/ springframework的/安全/弹簧安全配置/ 3.2.4.RELEASE /弹簧安全-CONFIG-3.2.4.RELEASE.jar
  • 组织/ springframework的/安全/弹簧安全标记库/ 3.2.4.RELEASE /弹簧安全标签库-3.2.4.RELEASE.jar
  • 组织/ springframework的/安全/弹簧安全-ACL / 3.2.4.RELEASE /弹簧安全-ACL-3.2.4.RELEASE.jar
  • 组织/ springframework的/安全/弹簧安全的Web / 3.2.4.RELEASE /弹簧安全web的3.2.4.RELEASE.jar
  • 公地的HttpClient /公地的HttpClient / 3.1 /公地HttpClient的-3.1.jar
  • 公地验证器/公地验证/ 1.2.0 /公地验证-1.2.0.jar
  • 公地的BeanUtils /公地的BeanUtils / 1.7.0 /公地BeanUtils的-1.7.0.jar
  • 公地消化器/公地消化器/ 1.6 /公地消化器-1.6.jar
  • 奥罗/奥罗/ 2.0.8 /口 - 2.0.8.jar
  • 公共网/公共网/ 3.3 /公地净3.3.jar
  • 了Javassist /了Javassist / 3.10.0.GA /了Javassist-3.10.0.GA.jar
  • 的PostgreSQL / PostgreSQL的/ 8.3-603.jdbc4 / PostgreSQL的-8.3-603.jdbc4.jar
  • 石英/石英/ 1.5.2 /石英1.5.2.jar
  • 组织/的freemarker /的freemarker / 2.3.9 / freemarker的-2.3.9.jar
  • Avalon的框架/ Avalon的框架/ 4.1.3 / Avalon的框架-4.1.3.jar
  • COM /太阳/ XML /消息/ SAAJ / SAAJ-IMPL / 1.3.1 / SAAJ-IMPL-1.3.1.jar
  • 的javax / XML / SOAP / SAAJ-API / 1.3 / SAAJ-API-1.3.jar
  • COM /辛/验证码/ JCaptcha的-所有/ 1.0-RC6 / JCaptcha的-所有-1.0-RC6.jar
  • 的javax /注解/ JSR250-API / 1.0 / JSR250-API-1.0.jar
  • 公地编解码器/公地编解码器/ 1.4 /公地编解码器-1.4.jar
  • 组织/ springframework的/弹簧核/ 4.0.5.RELEASE /弹簧芯4.0.5.RELEASE.jar
  • COM / ocpsoft / prettyfaces-jsf12 / 3.3.3 / prettyfaces-jsf12-3.3.3.jar
  • 组织/ RichFaces的/核心/ RichFaces的核 - IMPL / 4.3.7.Final / RichFaces的核 - IMPL-4.3.7.Final.jar
  • 组织/ RichFaces的/核心/ RichFaces的核-API / 4.3.7.Final / RichFaces的核-API-4.3.7.Final.jar
  • 净/ sourceforge的/ cssparser / cssparser / 0.9.5 / cssparser-0.9.5.jar
  • 组织/ W3C / CSS /囊/ 1.3 / SAC-1.3.jar
  • COM /谷歌/番石榴/番石榴/ 13.0.1 /番石榴13.0.1.jar
  • 组织/ RichFaces的/ UI / RichFaces的组件的UI / 4.3.7.Final / RichFaces的组件-UI-4.3.7.Final.jar
  • 组织/ RichFaces的/ UI / RichFaces的组件的API / 4.3.7.Final / RichFaces的组件-API-4.3.7.Final.jar
  • COM /太阳/面/ JSF-IMPL / 2.1.3 / JSF-IMPL-2.1.3.jar
  • COM /太阳/面/ JSF-API / 2.1.3 / JSF-API-2.1.3.jar
  • 公地构型/公地构型/ 1.10 /公地配置-1.10.jar
  • 组织/休眠/休眠核/ 4.2.16.Final /休眠核-4.2.16.Final.jar
  • ANTLR / ANTLR / 2.7.7 / ANTLR-2.7.7.jar
  • 组织/ JBoss的/记录/ JBoss的测井/ 3.1.0.GA / JBoss的测井-3.1.0.GA.jar
  • DOM4J / DOM4J / 1.6.1 / DOM4J-1.6.1.jar
  • 组织/了Javassist /了Javassist / 3.18.1-GA /了Javassist-3.18.1-GA.jar
  • 组织/ JBoss的/规格/的javax /交易/ JBoss的事务-api_1.1_spec / 1.0.1.Final / JBoss的事务-api_1.1_spec-1.0.1.Final.jar
  • 组织/休眠/的javax /持久/休眠-JPA-2.0-API / 1.0.1.Final /休眠-JPA-2.0-API-1.0.1.Final.jar
  • 的有机/休眠/普通/休眠-公地注解/ 4.0.2.Final /休眠-公地注解-4.0.2.Final.jar
  • 的javax / JMS / JMS-API / 1.1-REV-1 / JMS-API-1.1-REV-1.jar
  • 组织/阿帕奇/ xbean / xbean弹簧/ 4.1 / xbean - 弹簧 - 4.1.jar
  • 组织/阿帕奇/ ActiveMQ的/ ActiveMQ的-所有/ 5.12.1 / ActiveMQ的-全5.12.1.jar
  • 组织/ springframework的/弹簧-JMS / 4.0.5.RELEASE /弹簧-JMS-4.0.5.RELEASE.jar
  • 约达时间/乔达时间/ 2.7 /乔达 - 时间 - 2.7.jar
  • 组织/ springframework的/弹簧上下文支持/ 4.0.5.RELEASE /弹簧上下文支持-4.0.5.RELEASE.jar
  • 组织/ springframework的/弹簧豆/ 4.0.5.RELEASE /弹簧豆-4.0.5.RELEASE.jar
  • 组织/ springframework的/弹簧上下文/ 4.0.5.RELEASE /弹簧上下文4.0.5.RELEASE.jar
  • 净/ SF / ehcache的/ ehcache的/ 2.10.0 / ehcache的-2.10.0.jar
  • 组织/ SLF4J / SLF4J-API / 1.7.7 / SLF4J-API-1.7.7.jar
  • 的javax / servlet的/的javax.servlet-API / 3.0.1 /的javax.servlet-API-3.0.1.jar
  • WSDL4J / WSDL4J / 1.6.1 / WSDL4J-1.6.1.jar

我准备添加任何额外信息以找出这种情况的原因。我希望有人可以帮我找到解决这个问题的方法,因为Google并不知道这个问题。任何帮助都会有用。

2 个答案:

答案 0 :(得分:0)

将prettyfaces更改为JSF 2兼容版本(例如prettyfaces-jsf2-3.3.3.jar)

  

prettyfaces-jsf12 ... 适用于JSF 1.2, prettyfaces-jsf2 ... 适用于JSF 2.x(来自OCPSoft doc

,检查项目中是否正确定义。另外,您可以在 web.xml 中添加以下过滤器:

<filter>
    <filter-name>Pretty Filter</filter-name>
    <filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>Pretty Filter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>ERROR</dispatcher>
</filter-mapping>

答案 1 :(得分:0)

问题出现在以下依赖

Product.findOne({number: fields.number[0]}, function (err, product) {
    product.category = fields.category ? fields.category[0] : product.category;
    product.name = fields.name[0];

    product.save(function (err) {
        if(err) {
            console.error('ERROR!');
        }
    });
});

当我用

替换它时
com/ocpsoft/prettyfaces-jsf12/3.3.3/prettyfaces-jsf12-3.3.3.jar

对于JSF的第二个版本,问题已经消失