10 Replies Latest reply on Dec 6, 2006 12:53 PM by Gavin King

    Possible component.xml problem in 1.1.0 CR2

    Mike Quilleash Newbie

      Config:

      Tomcat 6.0.0
      JSF RI 1.2
      Facelets 1.1.11
      Hibernate 3.2.1
      Seam 1.1.0 CR2

      I have just downloaded CR2 and been trying to get a hibernate session auto-managed by Seam.

      I've got everything starting up ok in the Tomcat server but when I hit my test page I get the following.

      java.lang.NullPointerException
       at org.jboss.seam.jsf.SeamViewHandler.calculateLocale(SeamViewHandler.java:32)
       at com.sun.facelets.FaceletViewHandler.calculateLocale(FaceletViewHandler.java:771)
       at com.sun.faces.application.ViewHandlerImpl.createView(ViewHandlerImpl.java:356)
       at org.jboss.seam.jsf.SeamViewHandler.createView(SeamViewHandler.java:43)
       at com.sun.facelets.FaceletViewHandler.createView(FaceletViewHandler.java:782)
       at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:218)
       at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:244)
       at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:113)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:270)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:191)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:227)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:211)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:817)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:623)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:444)
       at java.lang.Thread.run(Thread.java:595)
      


      Which boils down to this call returning null

      Component.getInstance(LocaleSelector.class, ScopeType.SESSION)
      


      I've done some investigation and the problem looks to me to be in the component.xml in the META-INF/ of the jboss-seam.jar.

      The factory entries in there are of the form...

       <factory scope="stateless" auto-create="true" name="localeSelector" value="#{org.jboss.seam.core.localeSelector}"/>
      


      But if I take a look at the LocaleSelector class the @Name annonation is this..

      @Name("org.jboss.seam.core.localeSelector")
      


      The code in Init, where the factory maps are, is trying to match the name annotation value to the value in the xml which don't match. One has the package and the other does not.

      Am I doing something wrong here? I've stepped through the code and nothing funny is going on that I can see, just looks like the factoryValueBindings Map in Init uses different keys to the annotations specified in the classes.

      Any help/suggestions appreciated.

      Cheers.

      Mike.

        • 1. Re: Possible component.xml problem in 1.1.0 CR2
          Gavin King Master

          that factory mapping aliases the short name to the qualified name, so that is not the problem.

          • 2. Re: Possible component.xml problem in 1.1.0 CR2
            Gavin King Master

            Show me your components.xml file.

            • 3. Re: Possible component.xml problem in 1.1.0 CR2
              Mike Quilleash Newbie

              Cheers for the quick reply.

              My components.xml

              <components>
              
               <component name="referenceSession"
               class="org.jboss.seam.core.ManagedHibernateSession"/>
              
               <component name="hibernateSessionFactory"
               class="org.jboss.seam.core.HibernateSessionFactory"/>
              
              </components>
              


              Components.xml from jboss-seam.jar

              <!DOCTYPE components PUBLIC
               "-//JBoss/Seam Component Configuration DTD 1.1//EN"
               "http://jboss.com/products/seam/components-1.1.dtd">
              
              <components>
               <factory scope="stateless" auto-create="true" name="actor" value="#{org.jboss.seam.core.actor}"/>
               <factory scope="stateless" auto-create="true" name="applicationContext" value="#{org.jboss.seam.core.applicationContext}"/>
               <factory scope="stateless" auto-create="true" name="businessProcess" value="#{org.jboss.seam.core.businessProcess}"/>
               <factory scope="stateless" auto-create="true" name="businessProcessContext" value="#{org.jboss.seam.core.businessProcessContext}"/>
               <factory scope="stateless" auto-create="true" name="conversation" value="#{org.jboss.seam.core.conversation}"/>
               <factory scope="stateless" auto-create="true" name="conversationContext" value="#{org.jboss.seam.core.conversationContext}"/>
               <factory scope="stateless" auto-create="true" name="conversationList" value="#{org.jboss.seam.core.conversationList}"/>
               <factory scope="stateless" auto-create="true" name="conversationStack" value="#{org.jboss.seam.core.conversationStack}"/>
               <factory scope="stateless" auto-create="true" name="eventContext" value="#{org.jboss.seam.core.eventContext}"/>
               <factory scope="stateless" auto-create="true" name="events" value="#{org.jboss.seam.core.events}"/>
               <factory scope="stateless" auto-create="true" name="expressions" value="#{org.jboss.seam.core.expressions}"/>
               <factory scope="stateless" auto-create="true" name="facesContext" value="#{org.jboss.seam.core.facesContext}"/>
               <factory scope="stateless" auto-create="true" name="facesMessages" value="#{org.jboss.seam.core.facesMessages}"/>
               <factory scope="stateless" auto-create="true" name="httpError" value="#{org.jboss.seam.core.httpError}"/>
               <factory scope="stateless" auto-create="true" name="interpolator" value="#{org.jboss.seam.core.interpolator}"/>
               <factory scope="stateless" auto-create="true" name="isUserInRole" value="#{org.jboss.seam.core.isUserInRole}"/>
               <factory scope="stateless" auto-create="true" name="locale" value="#{org.jboss.seam.core.locale}"/>
               <factory scope="stateless" auto-create="true" name="localeSelector" value="#{org.jboss.seam.core.localeSelector}"/>
               <factory scope="stateless" auto-create="true" name="messages" value="#{org.jboss.seam.core.messages}"/>
               <factory scope="stateless" auto-create="true" name="jbpmContext" value="#{org.jboss.seam.core.jbpmContext}"/>
               <factory scope="stateless" auto-create="true" name="pageContext" value="#{org.jboss.seam.core.pageContext}"/>
               <factory scope="stateless" auto-create="true" name="pageflow" value="#{org.jboss.seam.core.pageflow}"/>
               <factory scope="stateless" auto-create="true" name="pojoCache" value="#{org.jboss.seam.core.pojoCache}"/>
               <factory scope="stateless" auto-create="true" name="pooledTask" value="#{org.jboss.seam.core.pooledTask}"/>
               <factory scope="stateless" auto-create="true" name="pooledTaskInstanceList" value="#{org.jboss.seam.core.pooledTaskInstanceList}"/>
               <factory scope="stateless" auto-create="true" name="processInstance" value="#{org.jboss.seam.core.processInstance}"/>
               <factory scope="stateless" auto-create="true" name="redirect" value="#{org.jboss.seam.core.redirect}"/>
               <factory scope="stateless" auto-create="true" name="resourceBundle" value="#{org.jboss.seam.core.resourceBundle}"/>
               <factory scope="stateless" auto-create="true" name="sessionContext" value="#{org.jboss.seam.core.sessionContext}"/>
               <factory scope="stateless" auto-create="true" name="switcher" value="#{org.jboss.seam.core.switcher}"/>
               <factory scope="stateless" auto-create="true" name="taskInstance" value="#{org.jboss.seam.core.taskInstance}"/>
               <factory scope="stateless" auto-create="true" name="taskInstanceList" value="#{org.jboss.seam.core.taskInstanceList}"/>
               <factory scope="stateless" auto-create="true" name="taskInstanceListForType" value="#{org.jboss.seam.core.taskInstanceListForType}"/>
               <factory scope="stateless" auto-create="true" name="timeZone" value="#{org.jboss.seam.core.timeZone}"/>
               <factory scope="stateless" auto-create="true" name="timeZoneSelector" value="#{org.jboss.seam.core.timeZoneSelector}"/>
               <factory scope="stateless" auto-create="true" name="transition" value="#{org.jboss.seam.core.transition}"/>
               <factory scope="stateless" auto-create="true" name="uiComponent" value="#{org.jboss.seam.core.uiComponent}"/>
               <factory scope="stateless" auto-create="true" name="userPrincipal" value="#{org.jboss.seam.core.userPrincipal}"/>
              
               <factory scope="stateless" auto-create="true" name="currentTime" value="#{org.jboss.seam.framework.currentTime}"/>
               <factory scope="stateless" auto-create="true" name="currentDate" value="#{org.jboss.seam.framework.currentDate}"/>
               <factory scope="stateless" auto-create="true" name="currentDatetime" value="#{org.jboss.seam.framework.currentDatetime}"/>
              
               <factory scope="stateless" auto-create="true" name="theme" value="#{org.jboss.seam.theme.theme}"/>
               <factory scope="stateless" auto-create="true" name="themeSelector" value="#{org.jboss.seam.theme.themeSelector}"/>
              
               <factory scope="stateless" auto-create="true" name="queueSession" value="#{org.jboss.seam.jms.queueSession}"/>
               <factory scope="stateless" auto-create="true" name="topicSession" value="#{org.jboss.seam.jms.topicSession}"/>
              </components>
              


              Bit more info.

              In the Component.getInstanceFromFactory() the String name passed in is org.jboss.seam.core.localeSelector

              Which is then used to call init.getFactory()/getFactoryMethodBinding()/getFactoryValueBinding(). I am guessing that the getFactoryValueBinding() should return something. The map factoryValueBindings in Init is populated but the keys are the short versions e.g. localeSelector, so null is returned from all 3 methods.

              Any specific info I can give to track this down please let me know.

              Cheers.


              • 4. Re: Possible component.xml problem in 1.1.0 CR2
                Gavin King Master

                No! Stop obsessing over factories! The way LocaleSelector should be instantiated is via newInstance() if the qualified name is passed. The factory stuff is for when the unqualified name is called.

                • 5. Re: Possible component.xml problem in 1.1.0 CR2
                  Mike Quilleash Newbie

                  Ok thanks. I've played around more and got a bit further but I think I'm in to work-around territory rather than fixing the problem properly.

                  Here is my current components.xml

                  <?xml version="1.0" encoding="UTF-8"?>
                  <components xmlns="http://jboss.com/products/seam/components"
                   xmlns:core="http://jboss.com/products/seam/core"
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xsi:schemaLocation=
                   "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-1.1.xsd
                   http://jboss.com/products/seam/components http://jboss.com/products/seam/components-1.1.xsd">
                  
                   <core:init debug="true"/>
                  
                   <!-- adding this makes the NPE go away -->
                   <core:locale-selector/>
                  
                   <core:managed-hibernate-session name="referenceSession"/>
                  
                   <core:hibernate-session-factory name="hibernateSessionFactory"/>
                  
                  </components>
                  


                  I added the locale-selector component here explicitly which forces it to load and means my web page serves up properly. However I still get a couple of other NPEs.

                  WARNING: phase(RESTORE_VIEW 1,com.sun.faces.context.FacesContextImpl@6fe350) threw exception: java.lang.NullPointerException null
                  org.jboss.seam.jsf.AbstractSeamPhaseListener.beforePhase(AbstractSeamPhaseListener.java:110)
                  org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:58)
                  com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:214)
                  com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:113)
                  javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
                  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:270)
                  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:191)
                  org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:227)
                  org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
                  org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                  org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
                  org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
                  org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:211)
                  org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:817)
                  org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:623)
                  org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:444)
                  java.lang.Thread.run(Thread.java:595)
                  
                  06-Oct-2006 11:03:27 com.sun.faces.lifecycle.LifecycleImpl phase
                  WARNING: phase(RENDER_RESPONSE 6,com.sun.faces.context.FacesContextImpl@6fe350) threw exception: java.lang.IllegalStateException: No Manager could be created, make sure the Component exists in application scope No Manager could be created, make sure the Component exists in application scope
                  org.jboss.seam.core.Manager.instance(Manager.java:254)
                  org.jboss.seam.jsf.AbstractSeamPhaseListener.beforeRender(AbstractSeamPhaseListener.java:184)
                  org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:51)
                  com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:214)
                  com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:140)
                  javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
                  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:270)
                  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:191)
                  org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:227)
                  org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
                  org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                  org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
                  org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
                  org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:211)
                  org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:817)
                  org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:623)
                  org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:444)
                  java.lang.Thread.run(Thread.java:595)
                  


                  Which are both similar to the locale problem. I found that the Component.forName(name) (which looks up components in the application context) call in Component.getInstance() is returning null. It was doing this for the locale-setting until I included it my components.xml but I don't think I should be putting all the core components in my components file.

                  I will keep investigating but any insight or ideas about why the core components don't seem to be loading automatically would be appreciated.

                  Thanks.

                  Mike.


                  • 6. Re: Possible component.xml problem in 1.1.0 CR2
                    Mike Quilleash Newbie

                    I have tracked it down, user error of course.

                    I was missing the javaassist jar file so it was barfing in the ComponentScanner when it looks at all the class files in the seam jar for the @name annotation.

                    At the moment the exception is caught and the error logged at debug level. Could this be changed to info/warn/error otherwise it can take a while to find classloading issues on components?

                    Thanks again.

                    Mike.

                    • 7. Re: Possible component.xml problem in 1.1.0 CR2
                      Gavin King Master

                      Ah. Ugh. I needed to catch NCDFE for other reasons, but it also swallows a missing javassist. Thanks.

                      • 8. Re: Possible component.xml problem in 1.1.0 CR2
                        Gavin King Master

                        I did a quick fix in CVS. Would you please do me a favor and test that for me, thanks.

                        • 9. Re: Possible component.xml problem in 1.1.0 CR2
                          Mike Quilleash Newbie

                          Tested without javaassist present

                          SEVERE: Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
                          java.lang.NoClassDefFoundError: javassist/bytecode/ClassFile
                           at org.jboss.seam.deployment.Scanner.<init>(Scanner.java:39)
                           at org.jboss.seam.deployment.Scanner.<init>(Scanner.java:32)
                           at org.jboss.seam.deployment.NamespaceScanner.<init>(NamespaceScanner.java:19)
                           at org.jboss.seam.init.Initialization.addNamespaces(Initialization.java:546)
                           at org.jboss.seam.init.Initialization.<init>(Initialization.java:79)
                           at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:65)
                           at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3826)
                           at org.apache.catalina.core.StandardContext.start(StandardContext.java:4335)
                           at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
                           at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
                           at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
                           at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:625)
                           at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:552)
                           at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:487)
                           at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1137)
                           at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
                           at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
                           at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1021)
                           at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
                           at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
                           at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
                           at org.apache.catalina.core.StandardService.start(StandardService.java:450)
                           at org.apache.catalina.core.StandardServer.start(StandardServer.java:709)
                           at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
                           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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:287)
                           at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:412)
                          


                          Looks good to me. Thanks for the quick fix.

                          Cheers.

                          Mike.