11 Replies Latest reply on Aug 15, 2007 1:23 AM by Raffi Khatchadourian

    problem configuring SMPC

    Adrian Mitev Master

      Hi all. I'm trying to configure SMPC on glass fish

      This is from components.xml

       <core:managed-persistence-context name="em"
       auto-create="true"
       persistence-unit-jndi-name="java:/SeamGenProject">
       </core:managed-persistence-context>
      


      This is from persistence.xml
      <persistence-unit name="SeamGenProject">
      .....
      


      As exception i get

      
      java.lang.IllegalArgumentException: EntityManagerFactory not found in JNDI
       at org.jboss.seam.core.ManagedPersistenceContext.getEntityManagerFactoryFromJndiOrValueBinding(ManagedPersistenceContext.java:164)
       at org.jboss.seam.core.ManagedPersistenceContext.initEntityManager(ManagedPersistenceContext.java:77)
       at org.jboss.seam.core.ManagedPersistenceContext.getEntityManager(ManagedPersistenceContext.java:105)
       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.seam.util.Reflections.invoke(Reflections.java:20)
       at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:123)
       at org.jboss.seam.Component.callComponentMethod(Component.java:1834)
       at org.jboss.seam.Component.unwrap(Component.java:1860)
       at org.jboss.seam.Component.getInstance(Component.java:1657)
       at org.jboss.seam.Component.getInstance(Component.java:1610)
       at org.jboss.seam.Component.getValueToInject(Component.java:1885)
       at org.jboss.seam.Component.injectAttributes(Component.java:1368)
       at org.jboss.seam.Component.inject(Component.java:1195)
       at org.jboss.seam.interceptors.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.interceptors.ManagedEntityIdentityInterceptor.aroundInvoke(ManagedEntityIdentityInterceptor.java:37)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.interceptors.ConversationInterceptor.aroundInvoke(ConversationInterceptor.java:54)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.interceptors.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:27)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103)
       at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:53)
       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 com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:560)
       at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:470)
       at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:192)
       at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:3922)
       at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:184)
       at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:114)
       at $Proxy331.begin(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:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:20)
       at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
       at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:72)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:57)
       at org.jboss.seam.interceptors.RemoveInterceptor.aroundInvoke(RemoveInterceptor.java:40)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103)
       at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:50)
       at org.javassist.tmp.java.lang.Object_$$_javassist_3.begin(Object_$$_javassist_3.java)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      
      Caused by: javax.naming.NameNotFoundException: No object bound to name java:/SeamGenProject
       at com.sun.enterprise.naming.NamingManagerImpl.lookup(NamingManagerImpl.java:807)
       at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:205)
       at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:313)
       at javax.naming.InitialContext.lookup(InitialContext.java:351)
       at org.jboss.seam.core.ManagedPersistenceContext.getEntityManagerFactoryFromJndiOrValueBinding(ManagedPersistenceContext.java:160)
       ... 113 more
      
      


      Idea what's wrong. I'm using seam 1.2.1.GA

        • 1. Re: problem configuring SMPC
          Jose Rubio Newbie

          Try adding this property to your persistence.xml file:

          <property name="jboss.entity.manager.factory.jndi.name"
           value="java:/SeamGenProject" />
          


          • 2. Re: problem configuring SMPC
            Adrian Mitev Master

            I have it. But this is for jboss. I'm using glass fish.

            • 3. Re: problem configuring SMPC
              Pete Muir Master

              You need to find out what jndi name Glassfish uses to expose the entity manager factory.

              • 4. Re: problem configuring SMPC
                Adrian Mitev Master

                Do i need to add persistence unit ref in the web.xml with GF?

                • 5. Re: problem configuring SMPC
                  Adrian Mitev Master

                  According to this [1] it won't work with jndi

                  [1] http://forums.java.net/jive/thread.jspa?messageID=207521

                  • 6. Re: problem configuring SMPC
                    Pete Muir Master

                    My reading of the JPA spec is that it requires the EntityManagerFactory to be exported to JNDI, but I will check what others think on this.

                    You should be able to do this using

                    <persistence:entityMangerFactory persistence-unit-name="SeamGenProject" name="entityManagerFactory" />
                    <persistence:managed-persistence-context name="entityManager" auto-create="true" entityManagerFactory="#{entityManagerFactory}" />


                    • 7. Re: problem configuring SMPC
                      Pete Muir Master

                      Sorry, I meant:

                      To work around the limitation in glassfish, use ...

                      • 8. Re: problem configuring SMPC
                        Christian Bauer Master

                        Unfortunately, the spec doesn't require JNDI binding except to the ENC of a Bean (useless crap).

                        • 9. Re: problem configuring SMPC
                          Adrian Mitev Master

                          I've added

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


                          But now i have another exception now:

                          Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
                          javax.persistence.PersistenceException: org.hibernate.HibernateException: The chosen transaction strategy requires access to the JTA TransactionManager
                           at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:720)
                           at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:121)
                           at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
                           at org.jboss.seam.core.EntityManagerFactory.startup(EntityManagerFactory.java:74)
                           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.seam.util.Reflections.invoke(Reflections.java:20)
                           at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:123)
                           at org.jboss.seam.Component.callComponentMethod(Component.java:1842)
                           at org.jboss.seam.Component.callCreateMethod(Component.java:1757)
                           at org.jboss.seam.Component.newInstance(Component.java:1746)
                           at org.jboss.seam.contexts.Lifecycle.startup(Lifecycle.java:175)
                           at org.jboss.seam.contexts.Lifecycle.endInitialization(Lifecycle.java:145)
                           at org.jboss.seam.init.Initialization.init(Initialization.java:504)
                           at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:33)
                           at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4493)
                           at org.apache.catalina.core.StandardContext.start(StandardContext.java:5150)
                           at com.sun.enterprise.web.WebModule.start(WebModule.java:308)
                           at com.sun.enterprise.web.LifecycleStarter.doRun(LifecycleStarter.java:45)
                           at com.sun.appserv.management.util.misc.RunnableBase.runSync(RunnableBase.java:283)
                           at com.sun.appserv.management.util.misc.RunnableBase._submit(RunnableBase.java:155)
                           at com.sun.appserv.management.util.misc.RunnableBase.submit(RunnableBase.java:171)
                           at com.sun.enterprise.web.VirtualServer.startChildren(VirtualServer.java:1566)
                           at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1218)
                           at org.apache.catalina.core.StandardHost.start(StandardHost.java:938)
                           at com.sun.enterprise.web.LifecycleStarter.doRun(LifecycleStarter.java:45)
                           at com.sun.appserv.management.util.misc.RunnableBase.runSync(RunnableBase.java:283)
                           at com.sun.appserv.management.util.misc.RunnableBase._submit(RunnableBase.java:155)
                           at com.sun.appserv.management.util.misc.RunnableBase.submit(RunnableBase.java:171)
                           at com.sun.enterprise.web.EmbeddedWebContainer$WebEngine.startChildren(EmbeddedWebContainer.java:440)
                           at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1218)
                           at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:520)
                           at org.apache.catalina.startup.Embedded.start(Embedded.java:923)
                           at com.sun.enterprise.web.WebContainer.start(WebContainer.java:852)
                           at com.sun.enterprise.web.PEWebContainer.startInstance(PEWebContainer.java:750)
                           at com.sun.enterprise.web.PEWebContainerLifecycle.onStartup(PEWebContainerLifecycle.java:71)
                           at com.sun.enterprise.server.ApplicationServer.onStartup(ApplicationServer.java:332)
                           at com.sun.enterprise.server.ondemand.OnDemandServer.onStartup(OnDemandServer.java:112)
                           at com.sun.enterprise.server.PEMain.run(PEMain.java:381)
                           at com.sun.enterprise.server.PEMain.main(PEMain.java:308)
                           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 com.sun.enterprise.server.PELaunch.main(PELaunch.java:274)
                          Caused by: org.hibernate.HibernateException: The chosen transaction strategy requires access to the JTA TransactionManager
                           at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:329)
                           at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1291)
                           at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:713)
                           ... 46 more
                          


                          even if i use <persistence-unit name="SeamGenProject" transaction-type="JTA">

                          • 11. Re: problem configuring SMPC
                            Raffi Khatchadourian Newbie

                            Did you switch your faces-config.xml to use:

                            <lifecycle>
                             <phase-listener>
                             org.jboss.seam.jsf.TransactionalSeamPhaseListener</phase-listener>
                            </lifecycle>