4 Replies Latest reply on Jul 27, 2009 11:01 PM by cdunphy

    Seam 2.1.2 , Glassfish 2.1, explode - deploy

    cardel.ka.jelinek.seznam.cz

      I am using Seam 2.1.2 and Glassfish 2.1


      I would like to see any seam-gen working example, which can be deployed to glassfish.


      Examples in seam distribution for glassfish (JPA, JEE5) are not generated with seam-gen. I tried to make same configuration in my seam-gen project, but with no effect.


      I made these steps:


      1) generate new seam-gen ear project
      2) make changes described in glassfish-readme.txt
      2.1) Uncomment the <ejb-local-ref> entries in resources/WEB-INF/web.xml (include additional entries as necessary)
      uncommented:


        <ejb-local-ref>
            <ejb-ref-name>sch/AuthenticatorBean/local</ejb-ref-name>
            <ejb-ref-type>Session</ejb-ref-type>
            <local-home/>
            <local>cz.mydomain.sch.action.Authenticator</local>
         </ejb-local-ref>
      



      2.2) Strip the contents up to and including the in the element <persistence-unit-name> in resources/WEB-INF/web.xml


      change



      <persistence-unit-name>../sch.jar#sch</persistence-unit-name>




      to



      <persistence-unit-name>sch</persistence-unit-name>





      2.3) Uncomment the <jar-file> element in resources/META-INF/persistence-dev.xml & resources/META-INF/persistence-prod.xml


      uncommented


      <jar-file>../../sch.jar</jar-file>



      3) Change <condition> in glassfish-build.xml (target gf-deploy-hibernate) because there is bug


      <condition>
          <or>
              <length string="${glassfish.home}" trim="true" length="0"/>
              <and>
                  <not><os family="windows"/></not>
                  <not><available file="${glassfish.home}/bin/asadmin"/></not>
              </and>
              <and>
                  <os family="windows"/>
                  <not><available file="${glassfish.home}/bin/asadmin.bat"/></not>
              </and>
          </or>
      </condition>



      Now I run these build targets:


      gf-start


      gf-deploy-hibernate


      gf-deploy or gf-explode


      and application works, I can login on login page


      Now I added EntityManager to AuthenticatorBean


      Add entityManager to AuthenticatorBean


      @PersistenceContext EntityManager entityManager;



      gf-explode give me this exception


      -> CLI171 Command deploy failed : Deploying application in domain failed; Could not resolve a persistence unit corresponding to the persistence-context-ref-name [cz.mydomain.sch.action.AuthenticatorBean/entityManager] in the scope of the module called []. Please verify your application.



      gf-deploy is OK in deployed application I can also use transactions


      @Resource UserTransaction tx;



      So with @PersistenceContext EntityManager entityManager I can only deploy whole application, no explode and hot-deploy (after change on some xhtml page etc..) is not available.


      Now I tried get EntityManager with @In annotation


      @In EntityManager entityManager;



      gf-explode, gf-deploy -> OK, application deployed or exploded, but I have exception on AuthenticatorBean.authenticate() method on login:



      [#|2009-07-15T17:26:25.485+0200|INFO|sun-
      
      appserver2.1|javax.enterprise.system.container.ejb|_ThreadID=26;_ThreadName=httpSSLWorkerThread-8081-0;|
      javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean; nested exception is: 
      
      java.lang.IllegalArgumentException: EntityManagerFactory not found in JNDI : java:comp/env/sch/pu
      java.lang.IllegalArgumentException: EntityManagerFactory not found in JNDI : java:comp/env/sch/pu
           at org.jboss.seam.persistence.ManagedPersistenceContext.getEntityManagerFactoryFromJndiOrValueBinding
      
      (ManagedPersistenceContext.java:245)
           at org.jboss.seam.persistence.ManagedPersistenceContext.initEntityManager(ManagedPersistenceContext.java:78)
           at org.jboss.seam.persistence.ManagedPersistenceContext.getEntityManager(ManagedPersistenceContext.java:107)
           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:597)
           at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
           at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
           at org.jboss.seam.Component.callComponentMethod(Component.java:2249)
           at org.jboss.seam.Component.unwrap(Component.java:2275)
           at org.jboss.seam.Component.getInstance(Component.java:2041)
           at org.jboss.seam.Component.getInstance(Component.java:1983)
           at org.jboss.seam.Component.getInstance(Component.java:1977)
           at org.jboss.seam.Component.getInstanceInAllNamespaces(Component.java:2349)
           at org.jboss.seam.Component.getValueToInject(Component.java:2301)
           at org.jboss.seam.Component.injectAttributes(Component.java:1736)
           at org.jboss.seam.Component.inject(Component.java:1554)
           at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:61)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.persistence.EntityManagerProxyInterceptor.aroundInvoke(EntityManagerProxyInterceptor.java:29)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.persistence.HibernateSessionProxyInterceptor.aroundInvoke(HibernateSessionProxyInterceptor.java:30)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
           at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:50)
           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:597)
           at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:579)
           at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:483)
           at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:205)
           at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4003)
           at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:197)
           at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:127)
           at $Proxy444.authenticate(Unknown Source)
           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:597)
           at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
           at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
           at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:76)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
           at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
           at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:54)
           at org.javassist.tmp.java.lang.Object_$$_javassist_seam_2.authenticate(Object_$$_javassist_seam_2.java)
           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:597)
           at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:335)
           at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:348)
           at org.jboss.el.parser.AstPropertySuffix.invoke(AstPropertySuffix.java:58)
           at org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
           at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
           at org.jboss.seam.core.Expressions$2.invoke(Expressions.java:175)
           at org.jboss.seam.security.jaas.SeamLoginModule.login(SeamLoginModule.java:109)
           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:597)
           at javax.security.auth.login.LoginContext.invoke(LoginContext.java:769)
           at javax.security.auth.login.LoginContext.access$000(LoginContext.java:186)
           at javax.security.auth.login.LoginContext$5.run(LoginContext.java:706)
           at java.security.AccessController.doPrivileged(Native Method)
           at javax.security.auth.login.LoginContext.invokeCreatorPriv(LoginContext.java:703)
           at javax.security.auth.login.LoginContext.login(LoginContext.java:575)
           at org.jboss.seam.security.Identity.authenticate(Identity.java:344)
           at org.jboss.seam.security.Identity.authenticate(Identity.java:332)
           at org.jboss.seam.security.Identity.login(Identity.java:259)
           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:597)
           at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:335)
           at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:348)
           at org.jboss.el.parser.AstPropertySuffix.invoke(AstPropertySuffix.java:58)
           at org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
           at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
           at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
           at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:77)
           at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
           at javax.faces.component.UICommand.broadcast(UICommand.java:383)
           at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:447)
           at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:752)
           at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
           at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
           at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
           at com.icesoft.faces.webapp.http.core.JsfLifecycleExecutor.apply(JsfLifecycleExecutor.java:16)
           at com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.renderCycle(ReceiveSendUpdates.java:114)
           at com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.service(ReceiveSendUpdates.java:66)
           at com.icesoft.faces.webapp.http.core.RequestVerifier.service(RequestVerifier.java:28)
           at com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer.service(PathDispatcherServer.java:24)
           at com.icesoft.faces.webapp.http.servlet.MainSessionBoundServlet.service(MainSessionBoundServlet.java:160)
           at com.icesoft.faces.webapp.http.servlet.SessionDispatcher$1.service(SessionDispatcher.java:42)
           at com.icesoft.faces.webapp.http.servlet.ThreadBlockingAdaptingServlet.service(ThreadBlockingAdaptingServlet.java:19)
           at com.icesoft.faces.webapp.http.servlet.EnvironmentAdaptingServlet.service(EnvironmentAdaptingServlet.java:63)
           at com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:62)
           at com.icesoft.faces.webapp.http.servlet.SessionVerifier.service(SessionVerifier.java:22)
           at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:23)
           at com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:153)
           at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
           at com.icesoft.faces.webapp.xmlhttp.BlockingServlet.service(BlockingServlet.java:56)
           at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:333)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
           at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:73)
           at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:313)
           at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:287)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:218)
           at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
           at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
           at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
           at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:98)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:222)
           at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
           at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
           at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
           at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096)
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:166)
           at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
           at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
           at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
           at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096)
           at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:288)
           at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:647)
           at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:579)
           at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:831)
           at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
           at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
           at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
           at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
           at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
      Caused by: javax.naming.NameNotFoundException: No object bound to name java:comp/env/sch/pu
           at com.sun.enterprise.naming.NamingManagerImpl.lookup(NamingManagerImpl.java:856)
           at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:173)
           at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:407)
           at javax.naming.InitialContext.lookup(InitialContext.java:392)
           at org.jboss.seam.persistence.ManagedPersistenceContext.getEntityManagerFactoryFromJndiOrValueBinding
      
      (ManagedPersistenceContext.java:241)
           ... 146 more



      Now I am not able to find any way to explode seam-gen application to GF and use hot-deploy or repeat explode after some litlle changes in my pages or POJOs.
      I am able only to deploy whole packaged application and this realy killing my productivity..



      Can you help me please? Thanks for any idea










        • 1. Re: Seam 2.1.2 , Glassfish 2.1, explode - deploy

          I have had the same issue for the longest time.  There are still problems with the way that the GlassFish seam-gen script works with 2.1.2.  Here is the workaround that I was able to use to fix the issues:


          1. Disable the ant target that moves the persistence.xml file to /WEB-INF/classes/META-INF.  Its better to keep everything in the EJB-JAR:


          <target name="gf-cleanup-ear" if="project.ear">
                    <!--
                    <move todir="${war.dir}/WEB-INF/classes">
                         <fileset dir="${jar.dir}">
                              <include name="META-INF/orm.xml" if="project.ear" />
                              <include name="META-INF/persistence.xml" if="project.ear" />
                         </fileset>
                    </move>
                    -->
          </target>




          2. Comment out the persistence-unit-ref entry in web.xml


          3. Don't try to lookup the seam managed context using @puJndiName@ in components.xml... instead use this:


          <persistence:entity-manager-factory
                    name="entityManagerFactory" persistence-unit-name="hello" />
          
               <persistence:managed-persistence-context
                    name="entityManager" auto-create="true" entity-manager-factory="#{entityManagerFactory}">
          



          4. Add ejb-transactions as well to components.xml (you need to add stuff to the namespace headers, see link at the end):


          <tx:ejb-transaction />




          5. Comment out the jboss.entity.manager.factory.jndi.name property in the persistence-dev.xml file.


          6. Add the following property to persistence-dev.xml:



          <property name="hibernate.transaction.manager_lookup_class"
               value="org.hibernate.transaction.SunONETransactionManagerLookup" />
          




          7. Add an EJB ref for org.jboss.seam.transaction.LocalEjbSynchronizations to web.xml:


          <ejb-local-ref>
                    <ejb-ref-name>hello/EjbSynchronizations/local</ejb-ref-name>
                    <ejb-ref-type>Session</ejb-ref-type>
                    <local-home />
                    <local>org.jboss.seam.transaction.LocalEjbSynchronizations</local>
               </ejb-local-ref>



          Make sure you add ejb-local-ref entries for all of the EJB session beans that you want to use.  Depending on how the components interact you may need to add entries to the ejb-jar.xml file as well.  The Seam reference documentation has some excellent information on deploying to other Java EE containers that you might want to check out as well.


          Hope that helps!


          // Chris

          • 2. Re: Seam 2.1.2 , Glassfish 2.1, explode - deploy

            This thread shows where I had the same issue...


            http://seamframework.org/Community/BugInSeamgenSeam212CR2ForGlassFishEARProjects


            It was a very simple hello world type app that I got was trying to get working.


            // Chris

            • 3. Re: Seam 2.1.2 , Glassfish 2.1, explode - deploy

              Correction... I got it working with less steps than that.


              1. Disable the ant target that moves the persistence.xml file to /WEB-INF/classes/META-INF. Its better to keep everything in the EJB-JAR:


              <target name="gf-cleanup-ear" if="project.ear">
                        <!--
                        <move todir="${war.dir}/WEB-INF/classes">
                             <fileset dir="${jar.dir}">
                                  <include name="META-INF/orm.xml" if="project.ear" />
                                  <include name="META-INF/persistence.xml" if="project.ear" />
                             </fileset>
                        </move>
                        -->
              </target>




              2. Comment out the persistence-unit-ref entry in web.xml.


              3. Don't try to lookup the seam managed context using @puJndiName@ in components.xml... instead use this (notice that I corrected an earlier mistake as I have properly closed the second tag):



              <persistence:entity-manager-factory
                        name="entityManagerFactory" persistence-unit-name="hello" />
              
              <persistence:managed-persistence-context
                        name="entityManager" auto-create="true" entity-manager-factory="#{entityManagerFactory}" />




              4. Add the following property to persistence-dev.xml (or persistence-prod.xml as needed):


              <property name="hibernate.transaction.manager_lookup_class"
                   value="org.hibernate.transaction.SunONETransactionManagerLookup" />




              So far I have gotten the workaround down to these 4 minimal steps.

              • 4. Re: Seam 2.1.2 , Glassfish 2.1, explode - deploy

                NOTE: These steps are taken AFTER you do all the steps in the glassfish-readme.txt file in the SEAM root.  Also, replace hello in my example with the name of your pu.