5 Replies Latest reply on Aug 5, 2009 11:41 PM by asookazian

    foo-a.b.c.d.ear instead of foo.ear to indicate build number

    asookazian

      So I refactored the ant build.xml in my seam-gen'd app so it's easier to tell what version of the app we're deploying (there's no manifest.mf unfortunately unless you use Ivy or Maven) and am running into a problem.  Basically the EAR is renamed but the JAR and WAR are not renamed. 


      <property name="ear.dir" value="exploded-archives/${project.name}-${buildNumber}.ear" />



      The EAR deploys fine in JBoss AS 4.2 but when I navigate to the home page of my app, I see this in the stack trace:


      Caused by: org.jboss.seam.InstantiationException: Could not instantiate Seam component: org.jboss.seam.transaction.synchronizations
           at org.jboss.seam.Component.newInstance(Component.java:1986)
           at org.jboss.seam.Component.getInstance(Component.java:1876)
           at org.jboss.seam.Component.getInstance(Component.java:1855)
           at org.jboss.seam.Component.getInstance(Component.java:1849)
           at org.jboss.seam.transaction.AbstractUserTransaction.getSynchronizations(AbstractUserTransaction.java:79)
           at org.jboss.seam.transaction.UTTransaction.commit(UTTransaction.java:48)
           at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:603)
           ... 50 more
      Caused by: javax.naming.NameNotFoundException: local 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.server.NamingServer.lookup(NamingServer.java:270)
           at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
           at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:667)
           at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
           at javax.naming.InitialContext.lookup(InitialContext.java:351)
           at org.jboss.seam.Component.instantiateSessionBean(Component.java:1290)
           at org.jboss.seam.Component.instantiate(Component.java:1276)
           at org.jboss.seam.Component.newInstance(Component.java:1970)
           ... 56 more



      I am using foo-1.0.0.1.ear to replace foo.ear.  I tried changing the jboss-app.xml from:


      <?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE jboss-app
          PUBLIC "-//JBoss//DTD J2EE Application 4.2//EN"
          "http://www.jboss.org/j2ee/dtd/jboss-app_4_2.dtd">
      
      <jboss-app>
         <loader-repository> 
            seam.jboss.org:loader=BETS
         </loader-repository> 
      </jboss-app> 



      to this:


      <?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE jboss-app
          PUBLIC "-//JBoss//DTD J2EE Application 4.2//EN"
          "http://www.jboss.org/j2ee/dtd/jboss-app_4_2.dtd">
      
      <jboss-app>
         <loader-repository> 
            seam.jboss.org:loader=BETS-1.0.0.1
         </loader-repository> 
      </jboss-app> 



      no affect.  exception reproduced.


      anybody know what I'm doing wrong?


      I added one line to my build-dev.properties:


      debug=true
      action.dir=WEB-INF/dev
      buildNumber=1.0.0.1



      application.xml:


      <?xml version="1.0" encoding="UTF-8"?>
      <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>BETS</display-name>
         
         <module>
            <web>
               <web-uri>BETS.war</web-uri>
               <context-root>/BETS</context-root>
            </web>
         </module>
          
         <module>
            <ejb>BETS.jar</ejb>
         </module>
         
         <!-- Seam and EL -->
         <module>
             <ejb>jboss-seam.jar</ejb>
         </module>    
          
      </application>

        • 1. Re: foo-a.b.c.d.ear instead of foo.ear to indicate build number
          asookazian

          After BETS-1.0.0.1.ear is deployed and I rename it to BETS.ear, everything is fine and the exception is not reproduced.

          • 2. Re: foo-a.b.c.d.ear instead of foo.ear to indicate build number
            asookazian

            server.log:


            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.contexts.FacesLifecycle] >>> Begin JSF request for /BETS/home.seam
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.transaction.transaction
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.transaction.transaction
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.transaction.transaction
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.core.Events] Processing event:org.jboss.seam.preSetVariable.org.jboss.seam.transaction.transaction
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.core.Events] Processing event:org.jboss.seam.postSetVariable.org.jboss.seam.transaction.transaction
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.core.Events] Processing event:org.jboss.seam.postCreate.org.jboss.seam.transaction.transaction
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.util.Naming] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
            2009-08-04 10:07:34,454 DEBUG [org.jboss.mx.loading.RepositoryClassLoader] setRepository, repository=org.jboss.mx.loading.HeirarchicalLoaderRepository3@48fe00, cl=org.jboss.mx.loading.HeirarchicalLoaderRepository3$CacheClassLoader@1433567{ url=null ,addedOrder=0}
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.util.Naming] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.jsf.SeamPhaseListener] beginning transaction prior to phase: RESTORE_VIEW 1
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.util.Naming] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.transaction.UTTransaction] beginning JTA transaction
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.transaction.synchronizations
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.util.Naming] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.core.Events] Processing event:org.jboss.seam.preRemoveVariable.org.jboss.seam.transaction.synchronizations
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
            2009-08-04 10:07:34,454 DEBUG [org.jboss.seam.core.Events] Processing event:org.jboss.seam.postRemoveVariable.org.jboss.seam.transaction.synchronizations
            2009-08-04 10:07:34,454 DEBUG [org.jboss.mx.loading.RepositoryClassLoader] setRepository, repository=org.jboss.mx.loading.HeirarchicalLoaderRepository3@48fe00, cl=org.jboss.mx.loading.HeirarchicalLoaderRepository3$CacheClassLoader@15a0b2f{ url=null ,addedOrder=0}
            2009-08-04 10:07:34,454 DEBUG [org.jboss.mx.loading.RepositoryClassLoader] setRepository, repository=org.jboss.mx.loading.HeirarchicalLoaderRepository3@48fe00, cl=org.jboss.mx.loading.HeirarchicalLoaderRepository3$CacheClassLoader@1507e9{ url=null ,addedOrder=0}
            2009-08-04 10:07:34,454 ERROR [org.jboss.seam.jsf.SeamPhaseListener] uncaught exception
            java.lang.IllegalStateException: Could not start transaction
                 at org.jboss.seam.jsf.SeamPhaseListener.begin(SeamPhaseListener.java:592)
                 at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsBeforePhase(SeamPhaseListener.java:323)
                 at org.jboss.seam.jsf.SeamPhaseListener.beforeServletPhase(SeamPhaseListener.java:140)
                 at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:114)
                 at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:214)
                 at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:96)
                 at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:104)
                 at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
                 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                 at jcifs.http.NtlmHttpFilter.doFilter(NtlmHttpFilter.java:125)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                 at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
                 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
            ..........................
            Caused by: org.jboss.seam.InstantiationException: Could not instantiate Seam component: org.jboss.seam.transaction.synchronizations
                 at org.jboss.seam.Component.newInstance(Component.java:1986)
                 at org.jboss.seam.Component.getInstance(Component.java:1876)
                 at org.jboss.seam.Component.getInstance(Component.java:1855)
                 at org.jboss.seam.Component.getInstance(Component.java:1849)
                 at org.jboss.seam.transaction.AbstractUserTransaction.getSynchronizations(AbstractUserTransaction.java:79)
                 at org.jboss.seam.transaction.UTTransaction.begin(UTTransaction.java:40)
                 at org.jboss.seam.jsf.SeamPhaseListener.begin(SeamPhaseListener.java:587)
                 ... 50 more
            Caused by: javax.naming.NameNotFoundException: BETS 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:267)
                 at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:667)
                 at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
                 at javax.naming.InitialContext.lookup(InitialContext.java:351)
                 at org.jboss.seam.Component.instantiateSessionBean(Component.java:1290)
                 at org.jboss.seam.Component.instantiate(Component.java:1276)
                 at org.jboss.seam.Component.newInstance(Component.java:1970)
                 ... 56 more

            • 3. Re: foo-a.b.c.d.ear instead of foo.ear to indicate build number
              asookazian

              Well, long story short, it was a JNDI lookup problem here:


              Component.java:


              protected Object instantiateSessionBean() throws Exception, NamingException
                 {
                    Component old = SeamInterceptor.COMPONENT.get();
                    SeamInterceptor.COMPONENT.set(this);
                    try
                    {
                       Object bean = Naming.getInitialContext().lookup(jndiName);
                       return wrap( bean, new ClientSideInterceptor(bean, this) );
                    }
                    finally
                    {
                       SeamInterceptor.COMPONENT.set(old);
                    }
                 }



              The root cause was in the war target of the build.xml script:


              <target name="war" depends="compile" 
                                      description="Build the distribution .war file">
                              .....                      
                              <copy todir="${war.dir}/WEB-INF">
                                   ....   
                                   <!-- filter token replaces @debug@ and @jndiPattern@ in components.xml -->                     
                                      <filterset>                             
                                          <filter token="debug" value="${debug}" />
                                          <filter token="jndiPattern" value="${project.name}-${buildNumber}/#{ejbName}/local" />
                                      </filterset>
                              </copy>   



              This line was the culprit and was fixed by adding buildNumber to the jndiPattern value:


              <filter token="jndiPattern" value="${project.name}-${buildNumber}/#{ejbName}/local" />



              It was:


              <filter token="jndiPattern" value="${project.name}/#{ejbName}/local" />



              I was unable to find the JNDI name in the jmx-console but you can see it outputted when JBoss deploys your Seam app in one of the private Component() constructors in Component class:


              log.info(
                          "Component: " + getName() +
                          ", scope: " + getScope() +
                          ", type: " + getType() +
                          ", class: " + getBeanClass().getName() +
                          ( jndiName==null ? "" : ", JNDI: " + jndiName )
                       );



              So apparently the lesson learned here is this:


              The prefix to the ejbName in the jndiPattern must match the name of your EAR file.


              So if your EAR is named foo-1.2.3.4.ear, then your EJB's jndiPattern must be foo-1.2.3.4/MyEjb/local.  The JNDI lookup will fail if you use foo/MyEjb/local as your jndiPattern.


              Please correct me if I'm wrong here.


              I did not change the contents of jboss-aop.xml, it's still this:


              <?xml version="1.0" encoding="UTF-8"?>
                <!DOCTYPE jboss-app
                  PUBLIC "-//JBoss//DTD J2EE Application 4.2//EN"
                  "http://www.jboss.org/j2ee/dtd/jboss-app_4_2.dtd">
              
              <jboss-app>
                 <loader-repository> 
                    seam.jboss.org:loader=BETS
                 </loader-repository> 
              </jboss-app> 



              Anybody explain why this is not included in seam-gen build by default?  Why wouldn't you want to see the build number in your EAR/WAR file name?  Esp. if a manifest.mf is not possible w/o Ivy or Maven, which are not standard in Seam 2.x apps?

              • 4. Re: foo-a.b.c.d.ear instead of foo.ear to indicate build number
                lelleh

                Arbi Sookazian wrote on Aug 04, 2009 19:23:


                (there's no manifest.mf unfortunately unless you use Ivy or Maven)


                I don't get what you say here. I use ant without Ivy and get e.g. Implementation-Version from the MANIFEST.MF of my jar if I don't do exploded deployments (that's ok, I don't need to know the version when developing).



                Arbi Sookazian wrote on Aug 04, 2009 19:23:

                <property name="ear.dir" value="exploded-archives/${project.name}-${buildNumber}.ear" />




                sounds dangerous, and you need to clean out the old ear manually when bumping buildnumber.



                So apparently the lesson learned here is this:

                The prefix to the ejbName in the jndiPattern must match the name of your EAR file.


                No, it is rather that the prefix must match the beginning of the jndi name where your bean can be found.


                (JBoss uses the ear file name to construct the jndi names. But you can use @org.jboss.annotation.ejb.LocalBinding to specify any jndiname for your ejbs, e.g. myear-without-buildnum/BETS/local)

                • 5. Re: foo-a.b.c.d.ear instead of foo.ear to indicate build number
                  asookazian

                  You're right, there is a useful manifest.mf if you add an ant target like this:


                  <target name="create-manifest" description="make the manifest">
                                 <tstamp>
                                      <format property="buildtime"
                                                pattern="yyyy-MM-dd'T'HH:mm:ss"/>
                                 </tstamp>
                                 <manifest file="${ear.dir}/META-INF/MANIFEST.MF">
                                           <attribute name="Built-By" value="asookazi"/>
                                           <attribute name="Built-On" value="${buildtime}"/>     
                                          <attribute name="Seam-Version" value="Seam 2.0.2-FP"/>
                                           <attribute name="Implementation-Version" value="${project.name} ${buildNumber}"/>
                                           <attribute name="Implementation-Vendor" value="Cox Communications, Inc."/>
                                 </manifest>
                            </target>



                  I will change the clean, undeploy and unexplode targets (if possible) to delete foo-* rather than foo-a.b.c.d.  Good catch.


                  I'll look at the JNDI tip with the @org.jboss.annotation.ejb.LocalBinding annotation as well.  I was unaware of that.  So I'm assuming the annotation at the class level will override the jndiPattern value...