users@glassfish.java.net

Re: GlassFish v2.1 and Hibernate Persistence

From: <glassfish_at_javadesktop.org>
Date: Sun, 09 Aug 2009 03:40:15 PDT

Still when i try to use hibernate as persistence provider it still throws this exception:
[i][b]javax.persistence.PersistenceException: No Persistence provider for EntityManager named columbusBD: Provider named org.hibernate.ejb.HibernatePersistence threw unexpected exception at create EntityManagerFactory:
javax.persistence.PersistenceException
javax.persistence.PersistenceException: [PersistenceUnit: columbusBD] Unable to build EntityManagerFactory
        at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:677)
        at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:126)
        at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:110)
        at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
        at org.columbus.businessDelegate.grafOlusturucuBD.GrafOlusturucuSessionBean.initialize(GrafOlusturucuSessionBean.java:38)
        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.BeanCallbackInterceptor.intercept(InterceptorManager.java:728)
        at com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(InterceptorManager.java:517)
        at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:221)
        at com.sun.ejb.containers.StatelessSessionContainer.createStatelessEJB(StatelessSessionContainer.java:563)
        at com.sun.ejb.containers.StatelessSessionContainer.access$100(StatelessSessionContainer.java:111)
        at com.sun.ejb.containers.StatelessSessionContainer$SessionContextFactory.create(StatelessSessionContainer.java:772)
        at com.sun.ejb.containers.util.pool.NonBlockingPool.getObject(NonBlockingPool.java:199)
        at com.sun.ejb.containers.StatelessSessionContainer._getContext(StatelessSessionContainer.java:486)
        at com.sun.ejb.containers.BaseContainer.getContext(BaseContainer.java:1700)
        at com.sun.ejb.containers.BaseContainer.preInvoke(BaseContainer.java:1229)
        at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:202)
        at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:117)
        at $Proxy60.getDuraklar(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 com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:154)
        at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:687)
        at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:227)
        at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1846)
        at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1706)
        at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:1088)
        at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:223)
        at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:806)
        at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispatch(CorbaMessageMediatorImpl.java:563)
        at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWork(CorbaMessageMediatorImpl.java:2567)
        at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)
Caused by: org.hibernate.HibernateException: The chosen transaction strategy requires access to the JTA TransactionManager
        at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:371)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1341)
        at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
        at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
        ... 36 more[/b][/i]


this is my persistence.xml:
[i][b]<persistence-unit name="columbusBD" transaction-type="JTA">
        
                
                <provider>org.hibernate.ejb.HibernatePersistence</provider>
                <jta-data-source>jdbc/ColumbusDS</jta-data-source>
                
                <class>org.columbus.businessDelegate.grafOlusturucuBD.DuraklarEntityBean</class>
                
                <exclude-unlisted-classes>true</exclude-unlisted-classes>
                
                <properties>
                <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
                <property name="hibernate.hbm2ddl.auto" value="none"/>
              </properties>
                
        </persistence-unit>[/b][/i]

And this my java code:
[i][b]@PostConstruct
        public void initialize() {
                fc = Persistence.createEntityManagerFactory("columbusBD");
                mgr = fc.createEntityManager();
        }
        
        @SuppressWarnings("unchecked")
        public List<DuraklarEntityBean> getDuraklar() {
                // TODO Auto-generated method stub
                
                Query q = null;
                
                q = mgr.createNativeQuery("SELECT D.NO FROM EBSYS.DURAK D","DuraklarResult");
                
                return q.getResultList();
        }[/b][/i]
and i integrate glassfish with hibernate as was taught on this web page :==>
[b]http://blogs.sun.com/GlassFishPersistence/entry/use_hibernate_as_a_persistence[/b]
[Message sent by forum member 'ilitheblack' (ilitheblack)]

http://forums.java.net/jive/thread.jspa?messageID=359600