12 Replies Latest reply on May 25, 2006 11:28 PM by littlesuns

    NullPointerException - rg.jboss.seam.contexts.PageContext.ge

    brianleonard

      Hi,

      I'm attempting to use Seam, but I'm stuck at this NullPointerException

      java.lang.NullPointerException
      org.jboss.seam.contexts.PageContext.getCurrentReadableMap(PageContext.java:62)
      org.jboss.seam.contexts.PageContext.get(PageContext.java:52)
      org.jboss.seam.core.Manager.restoreConversation(Manager.java:412)
      ...

      I can run the example's fine, so I know my server configuration is OK. It's trying to build the application from scratch that's causing me a problem. I've created a very simple reproduction here:

      http://testwww.netbeans.org/files/documents/71/819/SeamTest.ear

      It only has has a single JSP w/out any bindings. Basically, once I add the Seam phase-listener to the faces-config.xml and the SeamListener class to web.xml, the exception occurs. I assume that there's some other piece of configuration that I'm overlooking?

      Thanks,
      Brian

        • 1. Re: NullPointerException - rg.jboss.seam.contexts.PageContex
          gavin.king

          have you tried current CVS?

          • 2. Re: NullPointerException - rg.jboss.seam.contexts.PageContex
            brianleonard

            Of Seam or JBoss or both?

            • 3. Re: NullPointerException - rg.jboss.seam.contexts.PageContex
              gavin.king

              Seam.

              • 4. Re: NullPointerException - rg.jboss.seam.contexts.PageContex
                brianleonard

                Gavin,

                I got the same exception using the latest Seam CVS. I'm not surprised given the simplicity of my application. I posted a new ear, containing the freshly built jboss-seam.jar if you want to try it yourself. Once deployed, just hit:

                http://localhost:8080/SeamTest-war/welcomeJSF.seam

                The app just contains a simple JSP that outputs "Java Server Faces". I'd be curious to see if you get the same exception.

                Regards,
                Brian

                • 5. Re: NullPointerException - rg.jboss.seam.contexts.PageContex
                  gavin.king

                  So I tried to deploy this and I get:

                  23:25:33,171 WARN [ServiceController] Problem starting service persistence.units:ear=SeamTest.ear,unitName=SeamTest-ejb
                  javax.naming.NameNotFoundException: DefaultDS not bound
                   at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
                   at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
                   at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
                   at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
                   at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
                   at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
                   at javax.naming.InitialContext.lookup(InitialContext.java:351)
                   at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:240)
                   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                   at java.lang.reflect.Method.invoke(Method.java:585)
                   at org.jboss.ejb3.ServiceDelegateWrapper.startService(ServiceDelegateWrapper.java:99)
                  


                  Which is no surprise, since persistence.xml specifies DefaultDS instead of java:/DefaultDS.

                  • 6. Re: NullPointerException - rg.jboss.seam.contexts.PageContex
                    brianleonard

                    Ok, sorry, my bad. The PU issue wasn't the cause of my exception - I haven't even yet added persistence to this app. I've uploaded a new version of the ear if you would please try it again. I'd be curious to know if you DON'T get the NPE exception when you try to run it.

                    http://localhost:8080/SeamTest-war/welcomeJSF.seam

                    java.lang.NullPointerException
                    org.jboss.seam.contexts.PageContext.getCurrentReadableMap(PageContext.java:62)
                    org.jboss.seam.contexts.PageContext.get(PageContext.java:52)
                    org.jboss.seam.core.Manager.restoreConversation(Manager.java:412)
                    


                    Regards,
                    Brian

                    • 7. Re: NullPointerException - rg.jboss.seam.contexts.PageContex
                      gavin.king

                      The problem is that two different SeamPhaseListeners are being registered with JSF. One is in faces-config.xml. I'm trying to figure out where the other one comes from.

                      • 8. Re: NullPointerException - rg.jboss.seam.contexts.PageContex
                        acruise

                         

                        "gavin.king@jboss.com" wrote:
                        The problem is that two different SeamPhaseListeners are being registered with JSF. One is in faces-config.xml. I'm trying to figure out where the other one comes from.

                        I've got the identical stack trace.

                        • 9. Re: NullPointerException - rg.jboss.seam.contexts.PageContex
                          acruise

                           

                          "acruise" wrote:
                          "gavin.king@jboss.com" wrote:
                          The problem is that two different SeamPhaseListeners are being registered with JSF. One is in faces-config.xml. I'm trying to figure out where the other one comes from.

                          I've got the identical stack trace.


                          A few things that may be relevant...

                          I'm deploying this to JBoss 4.0.4CR2 as an .ear containing a .war and two ejb modules. It's is a copy of the registration tutorial, modified to work with my own User class, except the entities and session beans are contained in separate ejb modules.

                          - the .ear contains META-INF/application.xml, which looks like this:

                          <application 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/application_5.xsd"
                           version="5">
                           <display-name>Foo.com</display-name>
                           <module>
                           <web>
                           <web-uri>foo.war</web-uri>
                           <context-root>foo</context-root>
                           </web>
                           </module>
                          
                           <module>
                           <ejb>foo-seam.jar</ejb>
                           </module>
                          
                           <module>
                           <java>jboss-seam.jar</java>
                           </module>
                          
                           <module>
                           <ejb>foo-entities.jar</ejb>
                           </module>
                          
                          </application>
                          


                          - the first ejb module (foo-entities.jar) contains my entity beans classes and a persistence.xml;
                          - the other (foo-seam.jar) contains only RegisterAction.class, Register.class and the ejb-jar.xml declaring the Seam interceptor;
                          - the .war contains faces-config.xml, web.xml, register.jsp and registered.jsp.

                          • 10. Re: NullPointerException - rg.jboss.seam.contexts.PageContex
                            acruise

                            I modified my copy of Seam to throw, catch and log an exception when new SeamPhaseListeners are created; here's what it looks like:

                            16:46:06,687 INFO [FacesConfigurator] Reading standard config org/apache/myfaces/resource/standard-faces-config.xml
                            16:46:06,859 INFO [FacesConfigurator] Reading config jar:file:/C:/opt/java/jboss-4.0.4.CR2/server/default/tmp/deploy/tmp54830dvc.ear-contents/jboss-seam-ui.jar!/META-INF/faces-config.xml
                            16:46:06,906 INFO [FacesConfigurator] Reading config jar:file:/C:/opt/java/jboss-4.0.4.CR2/server/default/tmp/deploy/tmp54830dvc.ear-contents/jboss-seam.jar!/META-INF/faces-config.xml
                            16:46:06,937 INFO [FacesConfigurator] Reading config jar:file:/C:/opt/java/jboss-4.0.4.CR2/server/default/tmp/deploy/tmp54830dvc.ear-contents/dvc-exp.war/WEB-INF/lib/jboss-seam-ui.jar!/META-INF/faces-config.xml
                            16:46:06,984 INFO [FacesConfigurator] Reading config jar:file:/C:/opt/java/jboss-4.0.4.CR2/server/default/tmp/deploy/tmp54830dvc.ear-contents/dvc-exp.war/WEB-INF/lib/jboss-seam.jar!/META-INF/faces-config.xml
                            16:46:07,015 INFO [FacesConfigurator] Reading config /WEB-INF/faces-config.xml
                            16:46:07,062 INFO [FacesConfigurator] Reading config /WEB-INF/faces-config.xml
                            16:46:07,250 ERROR [STDERR] java.lang.RuntimeException: new SeamPhaseListener()
                            16:46:07,250 ERROR [STDERR] at org.jboss.seam.jsf.SeamPhaseListener.<init>(SeamPhaseListener.java:51)
                            16:46:07,250 ERROR [STDERR] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
                            16:46:07,250 ERROR [STDERR] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
                            16:46:07,250 ERROR [STDERR] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
                            16:46:07,250 ERROR [STDERR] at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
                            16:46:07,250 ERROR [STDERR] at java.lang.Class.newInstance0(Class.java:350)
                            16:46:07,250 ERROR [STDERR] at java.lang.Class.newInstance(Class.java:303)
                            16:46:07,250 ERROR [STDERR] at org.apache.myfaces.util.ClassUtils.newInstance(ClassUtils.java:274)
                            16:46:07,250 ERROR [STDERR] at org.apache.myfaces.util.ClassUtils.newInstance(ClassUtils.java:265)
                            16:46:07,250 ERROR [STDERR] at org.apache.myfaces.config.FacesConfigurator.configureLifecycle(FacesConfigurator.java:622)
                            16:46:07,250 ERROR [STDERR] at org.apache.myfaces.config.FacesConfigurator.configure(FacesConfigurator.java:133)
                            16:46:07,250 ERROR [STDERR] at org.apache.myfaces.webapp.StartupServletContextListener.initFaces(StartupServletContextListener.java:63)
                            16:46:07,250 ERROR [STDERR] at org.apache.myfaces.webapp.StartupServletContextListener.contextInitialized(StartupServletContextListener.java:46)
                            ...
                            


                            I'd guess that's what's interesting is that my /WEB-INF/faces-config.xml is getting read twice.

                            • 11. SOLVED! (was Re: NullPointerException - org.jboss.seam.conte
                              acruise

                              OK, I've gotten past this issue. MyFaces was loading my faces-config.xml twice, the first time because I had specified the following in web.xml:

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

                              And the second thanks to the usual automatic lookup of /WEB-INF/faces-config.xml.

                              I'd imagine this is a bug in MyFaces; IMO it shouldn't try to do the automatic lookup if the same resource has already been specified in a CONFIG_FILES context-param.

                              I removed the CONFIG_FILES context-param and It Just Worked(tm)

                              • 12. Re: NullPointerException - rg.jboss.seam.contexts.PageContex
                                littlesuns

                                I have got the samiliar exception in my app,i was use the jsf-impl of sun and did not specified the faces-config.xml in my web.xml: also can't find the other listener in my app,but i was use the noEjb and deployed a .war file,here is my stack trace:

                                java.lang.NullPointerException
                                 at org.jboss.seam.contexts.PageContext.getCurrentReadableMap(PageContext.java:62)
                                 at org.jboss.seam.contexts.PageContext.get(PageContext.java:52)
                                 at org.jboss.seam.contexts.Contexts.lookupInStatefulContexts(Contexts.java:125)
                                 at org.jboss.seam.Component.getInstance(Component.java:1038)
                                 at org.jboss.seam.jsf.SeamVariableResolver.resolveVariable(SeamVariableResolver.java:43)
                                 at com.sun.faces.el.VariableResolverChainWrapper.getValue(VariableResolverChainWrapper.java:71)
                                 at javax.el.CompositeELResolver.getValue(Unknown Source)
                                 at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:58)
                                 at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:65)
                                 at com.sun.el.parser.AstValue.getValue(AstValue.java:106)
                                 at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:192)
                                 at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
                                 at javax.faces.component.UIOutput.getValue(UIOutput.java:176)
                                 at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:100)
                                 at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:282)
                                 at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:208)
                                 at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:847)
                                 at javax.faces.component.UIComponent.encodeAll(UIComponent.java:893)
                                 at javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
                                 at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:827)
                                 at javax.faces.component.UIComponent.encodeAll(UIComponent.java:883)
                                 at javax.faces.component.UIComponent.encodeAll(UIComponent.java:889)
                                 at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:455)
                                 at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:108)
                                 at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:266)
                                 at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:159)
                                 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
                                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
                                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                                 at org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)
                                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                                 at com.subrain.web.servlet.filter.FacesContextHandler.doFilter(FacesContextHandler.java:102)
                                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                                 at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:44)
                                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                                 at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                                 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
                                 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
                                 at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:54)
                                 at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:174)
                                 at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
                                 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
                                 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
                                 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
                                 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
                                 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
                                 at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
                                 at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
                                 at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
                                 at java.lang.Thread.run(Thread.java:620)
                                

                                I was eager to know why,and it is appropriate to use current version of seam with a noejb env?


                                regards