NPE with url-mapping in PrimeFaces

Splash Forums PrettyFaces Users NPE with url-mapping in PrimeFaces

This topic contains 1 reply, has 2 voices, and was last updated by  Christian Kaltepoth 2 years, 8 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #25411

    Zhdislav
    Participant

    Good day.

    I searched and read related topics but did not find an answer.

    I use PrimeFaces 4 with Spring IoC and JavaBean tec. in my project. I use prettyfaces to get nice urls. All works fine except one: there is dublicated message in Tomcat Localhost Log file while request is processing.

    
    21-Nov-2013 16:08:11.176 SEVERE [tomcat-http--40] org.apache.catalina.core.ApplicationDispatcher.invoke Servlet.service() for servlet Faces Servlet threw exception
     java.lang.NullPointerException
    	at org.primefaces.context.PrimeFacesContext.release(PrimeFacesContext.java:26)
    	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:665)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    	at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:145)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
    	at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487)
    	at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412)
    	at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
    	at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:119)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    ...
    
    21-Nov-2013 16:08:11.176 SEVERE [tomcat-http--40] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [default] in context with path [/miles] threw exception
     java.lang.NullPointerException
    	at org.primefaces.context.PrimeFacesContext.release(PrimeFacesContext.java:26)
    	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:665)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    	at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:145)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
    	at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487)
    	at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412)
    	at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
    	at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:119)
    ...
    

    All config settings have not anything unusual.

    
    -- pretty-faces.xml
    <url-mapping id="common-template">
        <pattern value="/" />
        <view-id value="#{navigationBean.getSectionPath}" />
    </url-mapping>
    
    
    -- web.xml
        <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>
        <listener>
            <listener-class>org.springframework.web.context.request.RequestContextListener</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>/faces/*</url-pattern>
        </servlet-mapping>
        <servlet-mapping>
            <servlet-name>Faces Servlet</servlet-name>
            <url-pattern>*.xhtml</url-pattern>
        </servlet-mapping>
    
        <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>FORWARD</dispatcher>
            <dispatcher>REQUEST</dispatcher>
            <dispatcher>ERROR</dispatcher>
        </filter-mapping>
    

    navigationBean is request-scoped JavaBean. As in the example, it generates page address depending on whether the authorization.
    “/miles” is project folder name on server instance. So http://localhost:8080/miles -> “/”. The thing is for this request navigationBean.getSectionPath() returns “/faces/login.xhtml” for guest user. And login page is loaded in browser.

    If I replace #{navigationBean.getSectionPath} with static string, the error message does not appear. Please, help me understand what was going on?

    • This topic was modified 2 years, 8 months ago by  Zhdislav.
    #25413

    I’m not sure we can help you with this problem here, because this exception is thrown from the PrimeFaces code. The problem is in org.primefaces.context.PrimeFacesContext. You could have a look at the source code and check what is causing the NPE. Perhaps this will bring more light into this issue.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

Comments are closed.