Nikita R.
Nikita R.

Reputation: 43

NullPointerException after updating JSF to 2.1, Richfaces to 4.3.7

When updating

following this link

I got stuck with some strange exception

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)

which appears after submitting simple form on login.jspx page

<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 works as usual.

After updating I left .jspx page format.

I think that something wrong in configuration but can't find the reason.

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 header:

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

Here are libs, used in project:

I am ready to add any extra information to find a reason of this situation. I hope someone can help me to find out how to solve this problem, because Google doesn't know about this issue. Any help will be useful.

Upvotes: 0

Views: 634

Answers (2)

Nikita R.
Nikita R.

Reputation: 43

the problem was in the following dependency

com/ocpsoft/prettyfaces-jsf12/3.3.3/prettyfaces-jsf12-3.3.3.jar

when I replaced it with

com/ocpsoft/prettyfaces-jsf2/3.3.3/prettyfaces-jsf2-3.3.3.jar

for the second version of JSF, the problem has gone

Upvotes: 0

Vasil Lukach
Vasil Lukach

Reputation: 3728

Change prettyfaces to JSF 2 compatible version (for example prettyfaces-jsf2-3.3.3.jar)

prettyfaces-jsf12... is for JSF 1.2, prettyfaces-jsf2... is for JSF 2.x (from OCPSoft doc)

, check if it proper defined in your project. Plus you can add following filter in 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>

Upvotes: 1

Related Questions