Null Pointer Exception at com.ocpsoft.pretty.PrettyContext.getCurrentMapping …

Splash Forums PrettyFaces Users Null Pointer Exception at com.ocpsoft.pretty.PrettyContext.getCurrentMapping …

This topic contains 9 replies, has 3 voices, and was last updated by  clercmedia 6 years, 9 months ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #17840

    clercmedia
    Participant

    Hello guy’s , im new to PrettyFaces, and I want to put this nice features in my new project.

    Well , im having some difficulties now to make this work. Its not simple like in the little video for me and I dont understand what happened.

    This is the stack trace :

    java.lang.NullPointerException
    at com.ocpsoft.pretty.PrettyContext.getCurrentMapping(PrettyContext.java:198)
    at com.ocpsoft.pretty.PrettyContext.isPrettyRequest(PrettyContext.java:156)
    at com.ocpsoft.pretty.PrettyContext.shouldProcessDynaview(PrettyContext.java:236)
    at com.ocpsoft.pretty.faces.event.PrettyPhaseListener.beforePhase(PrettyPhaseListener.java:60)
    at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:224)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:95)
    at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:107)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:308)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:324)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
    at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285)
    at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261)
    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88)
    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951)
    at java.lang.Thread.run(Thread.java:637)

    Im using Jboss 6 with JSF2 and ICEFaces2.0.

    This is the content of my web-inf/lib

    /src/main/webapp/WEB-INF/lib/FastInfoset.jar

    /src/main/webapp/WEB-INF/lib/icefaces.jar

    /src/main/webapp/WEB-INF/lib/icefaces-ace.jar

    /src/main/webapp/WEB-INF/lib/icefaces-compat.jar

    /src/main/webapp/WEB-INF/lib/icepush.jar

    /src/main/webapp/WEB-INF/lib/jsf-api.jar

    /src/main/webapp/WEB-INF/lib/jsf-impl.jar

    /src/main/webapp/WEB-INF/lib/prettyfaces-jsf2-3.1.0.jar

    /src/main/webapp/WEB-INF/lib/tlddoc.jar

    I’ve got the file :

    /src/main/webapp/WEB-INF/pretty-config.xml

    The file is empty tough, I just want to make it work without any rewrite.

    So it’s like :

    <pretty-config xmlns="http://ocpsoft.com/prettyfaces/3.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://ocpsoft.com/prettyfaces/3.1.0
    http://ocpsoft.com/xml/ns/prettyfaces/ocpsoft-pretty-faces-3.1.0.xsd">

    </pretty-config>

    Well I ran the code in debug and i can see that in PrettyContext.java (line : 125)

    PrettyConfig prettyConfig = (PrettyConfig) request.getSession().getServletContext()
    .getAttribute(CONFIG_FILES_ATTR);

    prettyConfig is null so this is where my null pointer exception is coming from.

    So finally my question is : Why the value of prettyConfig is null ??

    Can anybody is able to help me with this, im kind of stuck here :( !

    Thanks

    Christian Leclerc,CSSLP,SCJP,OCBCD,ZCE

    christian.leclerc@s3s.ca

    http://www.s3s.ca

    #20520

    I’m guessing you have either incorrectly configured web.xml, or you are not using a Servlet 3.0 compliant container. What server are you using? I could be wrong :)

    #20521

    Lincoln, wasn’t there an issue with one of the latest JBoss 6 milestones that caused our filter not being picked up? I remember a ticket you created in the JBoss JIRA.

    #20522

    clercmedia
    Participant

    Hello guy’s,

    Thanks for your reply,

    I use : Jboss-6.0.0.CR1 but its the same on Jboss 4.2.3.

    JBoss 6 M2 supports Servlet 3 so I dont think this is a problem.

    Its maybe in the web.xml. I think iv’e done nothing in web.xml for PrettyFace.

    Its not in the little video. What I have to do in web.xml ?

    I will paste the content of my web.xml soon , im @ work and I use PF, for a personal project so …

    #20523

    clercmedia
    Participant

    Well Im lucky have access to the content here,

    <?xml version="1.0" encoding="UTF-8"?>
    <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
    license agreements. See the NOTICE file distributed with this work for additional
    information regarding copyright ownership. The ASF licenses this file to
    You under the Apache License, Version 2.0 (the "License"); you may not use
    this file except in compliance with the License. You may obtain a copy of
    the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
    by applicable law or agreed to in writing, software distributed under the
    License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
    OF ANY KIND, either express or implied. See the License for the specific
    language governing permissions and limitations under the License. -->

    <!-- - This is the Cocoon web-app configurations file - - $Id$ -->
    <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

    <context-param>
    <param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name>
    <param-value>true</param-value>
    </context-param>
    <context-param>
    <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
    <param-value>true</param-value>
    </context-param>
    <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>
    <context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
    </context-param>
    <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>index.html</welcome-file>
    </welcome-file-list>

    <login-config>
    <auth-method>FORM</auth-method>
    <form-login-config>
    <form-login-page>/login.jsf</form-login-page>
    <form-error-page>/login-failed.jsf</form-error-page>
    </form-login-config>
    </login-config>

    <security-constraint>
    <!-- Sample Security Constraint -->
    <web-resource-collection>

    <web-resource-name>protected-resources</web-resource-name>

    <url-pattern>/secur/*</url-pattern>

    <http-method>HEAD</http-method>
    <http-method>GET</http-method>
    <http-method>POST</http-method>
    <http-method>PUT</http-method>
    <http-method>DELETE</http-method>

    </web-resource-collection>

    <auth-constraint>
    <role-name>user</role-name>
    </auth-constraint>

    <user-data-constraint>
    <transport-guarantee>NONE</transport-guarantee>
    </user-data-constraint>

    </security-constraint>

    <security-role>
    <description>admin roles</description>
    <role-name>user</role-name>
    </security-role>

    </web-app>

    #20524

    Could you try to add this to your web.xml:

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

    This should not be necessary with a Servlet 3.0 container, but you could try it! :-)

    #20525

    clercmedia
    Participant

    hey I try to add the line in the web.xml but I had to ommit async-supported and ASYNC in the dispatcher because eclipse warn me that this is not in the dtd.

    Well now i’ve got error trying to start the filter :

    Exception starting filter Pretty Filter: java.lang.NoClassDefFoundError: org/apache/commons/digester/Digester

    at this point , it seam to be that iv’e got some dependencies problems.

    I will make this work and I will post back to tell you if I still got the null pointer exception. It should not happened again tough because the filter will be started and the value of the PrettyConfig will not be null … but just in case I will post back ;)

    Thanks !

    Chris.

    #20526

    Yeah, there was a strange issue with M4, I believe, that cause PrettyFaces to be ignored at boot time. I haven’t had this issue for a while, though, so if that’s it, I’d be surprised.

    I notice you said you’re using IceFaces, though, which historically does bad things to PrettyFaces. Hopefully that’s not the issue here; i know people have gotten icefaces working.

    #20527

    If the digester is missing, that would be a reason why PrettyConfig is not properly initialized. The prettyfaces dependencies (if not using maven) are listed on the home-page :)

    #20528

    clercmedia
    Participant

    Fix the dependencies problems,

    The NullPointerException is gone !

    Thanks for the help

    Have a nice day

    Chris.

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

You must be logged in to reply to this topic.

Comments are closed.