|
View:
New views
8 Messages
—
Rating Filter:
Alert me
|
|
|
EntityManager lookup difference between GF V2 and V3
Hi There,
We are trying out GF v3 for zembly.com and I am seeing following exception in obtaining EntityManager for EntityManagerFactory (em = emf.createEntityManager();): Caused by: Exception [EclipseLink-4021] (Eclipse Persistence Services - 1.0.1 (Build 20080905)): org.eclipse.persistence.exceptions.DatabaseException Exception Description: Unable to acquire a connection from driver [null], user [null] and URL [null]. Verify that you have set the expected driver class and URL. Check your login, persistence.xml or sessions.xml resource. The jdbc.driver property should be set to a class that is compatible with your database platform at org.eclipse.persistence.exceptions.DatabaseException.unableToAcquireConnectionFromDriverException(DatabaseException.java:365) at org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:90) Things work perfect with GF V2/2.1 but, V3 does not seem to work. Am I supposed to do something more than the following? Any tips would be much appreciated. Thanks, =Girish These are the configuration I have: System servlet has these 2 annotations reg PU: @PersistenceUnits( { @PersistenceUnit(name = "webonweb/repositoryEntityManagerFactory", unitName = "org.webonweb.runtime.impl.repository.db"), @PersistenceUnit(name = "webonweb/readOnlyRepositoryEntityManagerFactory", unitName = "org.webonweb.runtime.impl.repository.db.readonly") } ) Persistence.xml has (use introspection to discover all entities): <persistence-unit name="org.webonweb.runtime.impl.repository.db" transaction-type="RESOURCE_LOCAL"> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> <non-jta-data-source>jdbc/webonweb/repository</non-jta-data-source> <properties> <!-- <property name="toplink.logging.level" value="FINE"/> --> <!-- property name="toplink.logging.logger" value="JavaLogger"/ --> <!-- END JPA cache control properties --> <property name="eclipselink.cache.shared.default" value="true"/> <property name="eclipselink.logging.level" value="OFF"/> </properties> </persistence-unit> <persistence-unit name="org.webonweb.runtime.impl.repository.db.readonly" transaction-type="RESOURCE_LOCAL"> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> <non-jta-data-source>jdbc/webonweb/readonlyrepository</non-jta-data-source> <properties> <property name="eclipselink.cache.shared.default" value="true"/> <property name="eclipselink.logging.level" value="OFF"/> </properties> </persistence-unit> EMF was obtained by (got EMF with out any exception): protected EntityManagerFactory createEntityManagerFactory() throws RepositoryException { try { InitialContext ic = new InitialContext(); return (EntityManagerFactory) ic.lookup("java:comp/env/webonweb/repositoryEntityManagerFactory"); } catch (NamingException ne) { throw new RepositoryException(ne); } } protected EntityManagerFactory createReadOnlyEntityManagerFactory() throws RepositoryException { try { InitialContext ic = new InitialContext(); return (EntityManagerFactory) ic.lookup("java:comp/env/webonweb/readOnlyRepositoryEntityManagerFactory"); } catch (NamingException ne) { throw new RepositoryException(ne); } } Made sure that the data source is getting looked up correctly by the following code - hence not a config problem: private Connection getConnection() throws RepositoryException, SQLException { try { InitialContext ic = new InitialContext(); DataSource sd = (DataSource) ic.lookup("java:comp/env/jdbc/webonweb/repository"); return sd.getConnection(); } catch (NamingException ne) { throw new RepositoryException(ne); } } Version: Eclipse Persistence Services - 1.0.1 (Build 20080905) GF: GlassFish v3 Prelude (build b28f) |
|
|
Re: EntityManager lookup difference between GF V2 and V3
I am surprised that it worked in V2. You should be specifying
jta-data-source instead of non-jta-data-source in persitence.xml.
Somethig like as follows
<persistence-unit name="org.webonweb.runtime.impl.repository.db" transaction-type="RESOURCE_LOCAL"> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> <jta-data-source>jdbc/webonweb/repository</jta-data-source> Thanks, Mitesh Girish Kumar Balachandran wrote: Hi There, |
|
|
Re: EntityManager lookup difference between GF V2 and V3Mitesh, doesn't transaction-type="RESOURCE_LOCAL allow non-jta-data-source?
thanks, -marina Mitesh Meswani wrote: > I am surprised that it worked in V2. You should be specifying > jta-data-source instead of non-jta-data-source in persitence.xml. > Somethig like as follows > / <persistence-unit name="*org.webonweb.runtime.impl.repository.db*" > transaction-type="RESOURCE_LOCAL"> > <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> > <non-jta-data-source>*jdbc/webonweb/repository*</non-jta-data-source> > //<jta-data-source>*jdbc/webonweb/repository*</jta-data-source>/ > > Thanks, > Mitesh > > Girish Kumar Balachandran wrote: > >> Hi There, >> We are trying out GF v3 for zembly.com and I am seeing following >> exception in obtaining EntityManager for EntityManagerFactory (em = >> emf.createEntityManager();): >> / >> Caused by: Exception [EclipseLink-4021] (Eclipse Persistence Services >> - 1.0.1 (Build 20080905)): >> org.eclipse.persistence.exceptions.DatabaseException >> Exception Description: Unable to acquire a connection from driver >> [null], user [null] and URL [null]. Verify that you have set the >> expected driver class and URL. Check your login, persistence.xml or >> sessions.xml resource. The jdbc.driver property should be set to a >> class that is compatible with your database platform >> at >> org.eclipse.persistence.exceptions.DatabaseException.unableToAcquireConnectionFromDriverException(DatabaseException.java:365) >> at >> org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:90)/ >> >> Things work perfect with GF V2/2.1 but, V3 does not seem to work. Am I >> supposed to do something more than the following? >> >> Any tips would be much appreciated. >> >> Thanks, >> =Girish >> >> These are the configuration I have: >> * >> System servlet has these 2 annotations reg PU:* >> >> /@PersistenceUnits( >> { >> @PersistenceUnit(name = >> "*webonweb/repositoryEntityManagerFactory*", >> unitName = >> "*org.webonweb.runtime.impl.repository.db*"), >> @PersistenceUnit(name = >> "*webonweb/readOnlyRepositoryEntityManagerFactory*", >> unitName = >> "*org.webonweb.runtime.impl.repository.db.readonly*") >> } >> )/ >> >> >> *Persistence.xml has (use introspection to discover all entities):* >> >> / <persistence-unit name="*org.webonweb.runtime.impl.repository.db*" >> transaction-type="RESOURCE_LOCAL"> >> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> >> <non-jta-data-source>*jdbc/webonweb/repository*</non-jta-data-source> >> <properties> >> <!-- <property name="toplink.logging.level" value="FINE"/> --> >> <!-- property name="toplink.logging.logger" value="JavaLogger"/ --> >> <!-- END JPA cache control properties --> >> <property name="eclipselink.cache.shared.default" value="true"/> >> <property name="eclipselink.logging.level" value="OFF"/> >> </properties> >> </persistence-unit> >> <persistence-unit >> name="*org.webonweb.runtime.impl.repository.db.readonly*" >> transaction-type="RESOURCE_LOCAL"> >> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> >> >> <non-jta-data-source>*jdbc/webonweb/readonlyrepository*</non-jta-data-source> >> <properties> >> <property name="eclipselink.cache.shared.default" value="true"/> >> <property name="eclipselink.logging.level" value="OFF"/> >> </properties> >> </persistence-unit> >> / >> *EMF was obtained by (got EMF with out any exception):* >> >> /protected EntityManagerFactory createEntityManagerFactory() >> throws RepositoryException { >> try { >> InitialContext ic = new InitialContext(); >> return (EntityManagerFactory) >> ic.lookup("*java:comp/env/webonweb/repositoryEntityManagerFactory*"); >> } catch (NamingException ne) { >> throw new RepositoryException(ne); >> } >> } >> >> protected EntityManagerFactory >> createReadOnlyEntityManagerFactory() throws RepositoryException { >> try { >> InitialContext ic = new InitialContext(); >> return (EntityManagerFactory) >> ic.lookup("*java:comp/env/webonweb/readOnlyRepositoryEntityManagerFactory*"); >> } catch (NamingException ne) { >> throw new RepositoryException(ne); >> } >> }/ >> >> *Made sure that the data source is getting looked up correctly by the >> following code - hence not a config problem:* >> >> /private Connection getConnection() throws RepositoryException, >> SQLException { >> try { >> InitialContext ic = new InitialContext(); >> DataSource sd = (DataSource) >> ic.lookup("*java:comp/env/jdbc/webonweb/repository*"); >> return sd.getConnection(); >> } catch (NamingException ne) { >> throw new RepositoryException(ne); >> } >> } >> >> >> Version: Eclipse Persistence Services - 1.0.1 (Build 20080905) >> GF: GlassFish v3 Prelude (build b28f) >> >> / >> |
|
|
Re: EntityManager lookup difference between GF V2 and V3We manage our own EMs and do not depend on the container. BTW, the
difference between V2 and V3 usage in ours is, in V2 we did not use eclipse link in V3 we are also trying out eclipse link. Apologies for not mentioning it. So, would that be a reason why it is working for us in V2? =Girish Marina Vatkina wrote: > Mitesh, doesn't transaction-type="RESOURCE_LOCAL allow > non-jta-data-source? > > thanks, > -marina > > Mitesh Meswani wrote: >> I am surprised that it worked in V2. You should be specifying >> jta-data-source instead of non-jta-data-source in persitence.xml. >> Somethig like as follows >> / <persistence-unit name="*org.webonweb.runtime.impl.repository.db*" >> transaction-type="RESOURCE_LOCAL"> >> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> >> >> <non-jta-data-source>*jdbc/webonweb/repository*</non-jta-data-source> >> //<jta-data-source>*jdbc/webonweb/repository*</jta-data-source>/ >> >> Thanks, >> Mitesh >> >> Girish Kumar Balachandran wrote: >> >>> Hi There, >>> We are trying out GF v3 for zembly.com and I am seeing following >>> exception in obtaining EntityManager for EntityManagerFactory (em = >>> emf.createEntityManager();): >>> / >>> Caused by: Exception [EclipseLink-4021] (Eclipse Persistence >>> Services - 1.0.1 (Build 20080905)): >>> org.eclipse.persistence.exceptions.DatabaseException >>> Exception Description: Unable to acquire a connection from driver >>> [null], user [null] and URL [null]. Verify that you have set the >>> expected driver class and URL. Check your login, persistence.xml or >>> sessions.xml resource. The jdbc.driver property should be set to a >>> class that is compatible with your database platform >>> at >>> org.eclipse.persistence.exceptions.DatabaseException.unableToAcquireConnectionFromDriverException(DatabaseException.java:365) >>> >>> at >>> org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:90)/ >>> >>> >>> Things work perfect with GF V2/2.1 but, V3 does not seem to work. Am >>> I supposed to do something more than the following? >>> >>> Any tips would be much appreciated. >>> >>> Thanks, >>> =Girish >>> >>> These are the configuration I have: >>> * >>> System servlet has these 2 annotations reg PU:* >>> >>> /@PersistenceUnits( >>> { >>> @PersistenceUnit(name = >>> "*webonweb/repositoryEntityManagerFactory*", >>> unitName = >>> "*org.webonweb.runtime.impl.repository.db*"), >>> @PersistenceUnit(name = >>> "*webonweb/readOnlyRepositoryEntityManagerFactory*", >>> unitName = >>> "*org.webonweb.runtime.impl.repository.db.readonly*") >>> } >>> )/ >>> >>> >>> *Persistence.xml has (use introspection to discover all entities):* >>> >>> / <persistence-unit >>> name="*org.webonweb.runtime.impl.repository.db*" >>> transaction-type="RESOURCE_LOCAL"> >>> >>> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> >>> >>> <non-jta-data-source>*jdbc/webonweb/repository*</non-jta-data-source> >>> <properties> >>> <!-- <property name="toplink.logging.level" value="FINE"/> --> >>> <!-- property name="toplink.logging.logger" >>> value="JavaLogger"/ --> >>> <!-- END JPA cache control properties --> >>> <property name="eclipselink.cache.shared.default" value="true"/> >>> <property name="eclipselink.logging.level" value="OFF"/> >>> </properties> >>> </persistence-unit> >>> <persistence-unit >>> name="*org.webonweb.runtime.impl.repository.db.readonly*" >>> transaction-type="RESOURCE_LOCAL"> >>> >>> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> >>> >>> <non-jta-data-source>*jdbc/webonweb/readonlyrepository*</non-jta-data-source> >>> >>> <properties> >>> <property name="eclipselink.cache.shared.default" value="true"/> >>> <property name="eclipselink.logging.level" value="OFF"/> >>> </properties> >>> </persistence-unit> >>> / >>> *EMF was obtained by (got EMF with out any exception):* >>> >>> /protected EntityManagerFactory createEntityManagerFactory() >>> throws RepositoryException { >>> try { >>> InitialContext ic = new InitialContext(); >>> return (EntityManagerFactory) >>> ic.lookup("*java:comp/env/webonweb/repositoryEntityManagerFactory*"); >>> } catch (NamingException ne) { >>> throw new RepositoryException(ne); >>> } >>> } >>> protected EntityManagerFactory >>> createReadOnlyEntityManagerFactory() throws RepositoryException { >>> try { >>> InitialContext ic = new InitialContext(); >>> return (EntityManagerFactory) >>> ic.lookup("*java:comp/env/webonweb/readOnlyRepositoryEntityManagerFactory*"); >>> >>> } catch (NamingException ne) { >>> throw new RepositoryException(ne); >>> } >>> }/ >>> >>> *Made sure that the data source is getting looked up correctly by >>> the following code - hence not a config problem:* >>> >>> /private Connection getConnection() throws RepositoryException, >>> SQLException { >>> try { >>> InitialContext ic = new InitialContext(); >>> DataSource sd = (DataSource) >>> ic.lookup("*java:comp/env/jdbc/webonweb/repository*"); >>> return sd.getConnection(); >>> } catch (NamingException ne) { >>> throw new RepositoryException(ne); >>> } >>> } >>> >>> >>> Version: Eclipse Persistence Services - 1.0.1 (Build 20080905) >>> GF: GlassFish v3 Prelude (build b28f) >>> >>> / >>> > |
|
|
Re: EntityManager lookup difference between GF V2 and V3Hmm...I did not notice transaction type being RESOURCE_LOCAL.
Girish, Are you sure you are deploying the persitence.xml as below, it should not get past deploy as for container managed EMFs the only JTA transaction-type is allowed. Thanks, Mitesh Marina Vatkina wrote: > Mitesh, doesn't transaction-type="RESOURCE_LOCAL allow > non-jta-data-source? > > thanks, > -marina > > Mitesh Meswani wrote: >> I am surprised that it worked in V2. You should be specifying >> jta-data-source instead of non-jta-data-source in persitence.xml. >> Somethig like as follows >> / <persistence-unit name="*org.webonweb.runtime.impl.repository.db*" >> transaction-type="RESOURCE_LOCAL"> >> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> >> >> <non-jta-data-source>*jdbc/webonweb/repository*</non-jta-data-source> >> //<jta-data-source>*jdbc/webonweb/repository*</jta-data-source>/ >> >> Thanks, >> Mitesh >> >> Girish Kumar Balachandran wrote: >> >>> Hi There, >>> We are trying out GF v3 for zembly.com and I am seeing following >>> exception in obtaining EntityManager for EntityManagerFactory (em = >>> emf.createEntityManager();): >>> / >>> Caused by: Exception [EclipseLink-4021] (Eclipse Persistence >>> Services - 1.0.1 (Build 20080905)): >>> org.eclipse.persistence.exceptions.DatabaseException >>> Exception Description: Unable to acquire a connection from driver >>> [null], user [null] and URL [null]. Verify that you have set the >>> expected driver class and URL. Check your login, persistence.xml or >>> sessions.xml resource. The jdbc.driver property should be set to a >>> class that is compatible with your database platform >>> at >>> org.eclipse.persistence.exceptions.DatabaseException.unableToAcquireConnectionFromDriverException(DatabaseException.java:365) >>> >>> at >>> org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:90)/ >>> >>> >>> Things work perfect with GF V2/2.1 but, V3 does not seem to work. Am >>> I supposed to do something more than the following? >>> >>> Any tips would be much appreciated. >>> >>> Thanks, >>> =Girish >>> >>> These are the configuration I have: >>> * >>> System servlet has these 2 annotations reg PU:* >>> >>> /@PersistenceUnits( >>> { >>> @PersistenceUnit(name = >>> "*webonweb/repositoryEntityManagerFactory*", >>> unitName = >>> "*org.webonweb.runtime.impl.repository.db*"), >>> @PersistenceUnit(name = >>> "*webonweb/readOnlyRepositoryEntityManagerFactory*", >>> unitName = >>> "*org.webonweb.runtime.impl.repository.db.readonly*") >>> } >>> )/ >>> >>> >>> *Persistence.xml has (use introspection to discover all entities):* >>> >>> / <persistence-unit >>> name="*org.webonweb.runtime.impl.repository.db*" >>> transaction-type="RESOURCE_LOCAL"> >>> >>> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> >>> >>> <non-jta-data-source>*jdbc/webonweb/repository*</non-jta-data-source> >>> <properties> >>> <!-- <property name="toplink.logging.level" value="FINE"/> --> >>> <!-- property name="toplink.logging.logger" >>> value="JavaLogger"/ --> >>> <!-- END JPA cache control properties --> >>> <property name="eclipselink.cache.shared.default" value="true"/> >>> <property name="eclipselink.logging.level" value="OFF"/> >>> </properties> >>> </persistence-unit> >>> <persistence-unit >>> name="*org.webonweb.runtime.impl.repository.db.readonly*" >>> transaction-type="RESOURCE_LOCAL"> >>> >>> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> >>> >>> <non-jta-data-source>*jdbc/webonweb/readonlyrepository*</non-jta-data-source> >>> >>> <properties> >>> <property name="eclipselink.cache.shared.default" value="true"/> >>> <property name="eclipselink.logging.level" value="OFF"/> >>> </properties> >>> </persistence-unit> >>> / >>> *EMF was obtained by (got EMF with out any exception):* >>> >>> /protected EntityManagerFactory createEntityManagerFactory() >>> throws RepositoryException { >>> try { >>> InitialContext ic = new InitialContext(); >>> return (EntityManagerFactory) >>> ic.lookup("*java:comp/env/webonweb/repositoryEntityManagerFactory*"); >>> } catch (NamingException ne) { >>> throw new RepositoryException(ne); >>> } >>> } >>> protected EntityManagerFactory >>> createReadOnlyEntityManagerFactory() throws RepositoryException { >>> try { >>> InitialContext ic = new InitialContext(); >>> return (EntityManagerFactory) >>> ic.lookup("*java:comp/env/webonweb/readOnlyRepositoryEntityManagerFactory*"); >>> >>> } catch (NamingException ne) { >>> throw new RepositoryException(ne); >>> } >>> }/ >>> >>> *Made sure that the data source is getting looked up correctly by >>> the following code - hence not a config problem:* >>> >>> /private Connection getConnection() throws RepositoryException, >>> SQLException { >>> try { >>> InitialContext ic = new InitialContext(); >>> DataSource sd = (DataSource) >>> ic.lookup("*java:comp/env/jdbc/webonweb/repository*"); >>> return sd.getConnection(); >>> } catch (NamingException ne) { >>> throw new RepositoryException(ne); >>> } >>> } >>> >>> >>> Version: Eclipse Persistence Services - 1.0.1 (Build 20080905) >>> GF: GlassFish v3 Prelude (build b28f) >>> >>> / >>> > |
|
|
Re: EntityManager lookup difference between GF V2 and V3Hi Mitesh,
I made sure that this perstence.xml is being used by making a XML validation error in I got this exception, hence I think this persitence is being read. SEVERE: Exception while invoking class com.sun.enterprise.web.WebDeployer prepare method java.lang.RuntimeException: Deployment descriptor file META-INF/persistence.xml in archive [wow-repository-db.jar]. The element type "rovider" must be terminated by the matching end-tag "</rovider>". at org.glassfish.javaee.core.deployment.JavaEEDeployer.loadMetaData(JavaEEDeployer.java:160) I modified as per your suggestion to jta-data-source and I still see the exact same error message:( Thanks, =Girish Mitesh Meswani wrote: > Hmm...I did not notice transaction type being RESOURCE_LOCAL. > > Girish, > Are you sure you are deploying the persitence.xml as below, it should > not get past deploy as for container managed EMFs the only JTA > transaction-type is allowed. > > Thanks, > Mitesh > > Marina Vatkina wrote: >> Mitesh, doesn't transaction-type="RESOURCE_LOCAL allow >> non-jta-data-source? >> >> thanks, >> -marina >> >> Mitesh Meswani wrote: >>> I am surprised that it worked in V2. You should be specifying >>> jta-data-source instead of non-jta-data-source in persitence.xml. >>> Somethig like as follows >>> / <persistence-unit >>> name="*org.webonweb.runtime.impl.repository.db*" >>> transaction-type="RESOURCE_LOCAL"> >>> >>> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> >>> >>> <non-jta-data-source>*jdbc/webonweb/repository*</non-jta-data-source> >>> //<jta-data-source>*jdbc/webonweb/repository*</jta-data-source>/ >>> >>> Thanks, >>> Mitesh >>> >>> Girish Kumar Balachandran wrote: >>> >>>> Hi There, >>>> We are trying out GF v3 for zembly.com and I am seeing following >>>> exception in obtaining EntityManager for EntityManagerFactory (em = >>>> emf.createEntityManager();): >>>> / >>>> Caused by: Exception [EclipseLink-4021] (Eclipse Persistence >>>> Services - 1.0.1 (Build 20080905)): >>>> org.eclipse.persistence.exceptions.DatabaseException >>>> Exception Description: Unable to acquire a connection from driver >>>> [null], user [null] and URL [null]. Verify that you have set the >>>> expected driver class and URL. Check your login, persistence.xml >>>> or sessions.xml resource. The jdbc.driver property should be set >>>> to a class that is compatible with your database platform >>>> at >>>> org.eclipse.persistence.exceptions.DatabaseException.unableToAcquireConnectionFromDriverException(DatabaseException.java:365) >>>> >>>> at >>>> org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:90)/ >>>> >>>> >>>> Things work perfect with GF V2/2.1 but, V3 does not seem to work. >>>> Am I supposed to do something more than the following? >>>> >>>> Any tips would be much appreciated. >>>> >>>> Thanks, >>>> =Girish >>>> >>>> These are the configuration I have: >>>> * >>>> System servlet has these 2 annotations reg PU:* >>>> >>>> /@PersistenceUnits( >>>> { >>>> @PersistenceUnit(name = >>>> "*webonweb/repositoryEntityManagerFactory*", >>>> unitName = >>>> "*org.webonweb.runtime.impl.repository.db*"), >>>> @PersistenceUnit(name = >>>> "*webonweb/readOnlyRepositoryEntityManagerFactory*", >>>> unitName = >>>> "*org.webonweb.runtime.impl.repository.db.readonly*") >>>> } >>>> )/ >>>> >>>> >>>> *Persistence.xml has (use introspection to discover all entities):* >>>> >>>> / <persistence-unit >>>> name="*org.webonweb.runtime.impl.repository.db*" >>>> transaction-type="RESOURCE_LOCAL"> >>>> >>>> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> >>>> >>>> <non-jta-data-source>*jdbc/webonweb/repository*</non-jta-data-source> >>>> <properties> >>>> <!-- <property name="toplink.logging.level" value="FINE"/> --> >>>> <!-- property name="toplink.logging.logger" >>>> value="JavaLogger"/ --> >>>> <!-- END JPA cache control properties --> >>>> <property name="eclipselink.cache.shared.default" value="true"/> >>>> <property name="eclipselink.logging.level" value="OFF"/> >>>> </properties> >>>> </persistence-unit> >>>> <persistence-unit >>>> name="*org.webonweb.runtime.impl.repository.db.readonly*" >>>> transaction-type="RESOURCE_LOCAL"> >>>> >>>> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> >>>> >>>> <non-jta-data-source>*jdbc/webonweb/readonlyrepository*</non-jta-data-source> >>>> >>>> <properties> >>>> <property name="eclipselink.cache.shared.default" value="true"/> >>>> <property name="eclipselink.logging.level" value="OFF"/> >>>> </properties> >>>> </persistence-unit> >>>> / >>>> *EMF was obtained by (got EMF with out any exception):* >>>> >>>> /protected EntityManagerFactory createEntityManagerFactory() >>>> throws RepositoryException { >>>> try { >>>> InitialContext ic = new InitialContext(); >>>> return (EntityManagerFactory) >>>> ic.lookup("*java:comp/env/webonweb/repositoryEntityManagerFactory*"); >>>> } catch (NamingException ne) { >>>> throw new RepositoryException(ne); >>>> } >>>> } >>>> protected EntityManagerFactory >>>> createReadOnlyEntityManagerFactory() throws RepositoryException { >>>> try { >>>> InitialContext ic = new InitialContext(); >>>> return (EntityManagerFactory) >>>> ic.lookup("*java:comp/env/webonweb/readOnlyRepositoryEntityManagerFactory*"); >>>> >>>> } catch (NamingException ne) { >>>> throw new RepositoryException(ne); >>>> } >>>> }/ >>>> >>>> *Made sure that the data source is getting looked up correctly by >>>> the following code - hence not a config problem:* >>>> >>>> /private Connection getConnection() throws RepositoryException, >>>> SQLException { >>>> try { >>>> InitialContext ic = new InitialContext(); >>>> DataSource sd = (DataSource) >>>> ic.lookup("*java:comp/env/jdbc/webonweb/repository*"); >>>> return sd.getConnection(); >>>> } catch (NamingException ne) { >>>> throw new RepositoryException(ne); >>>> } >>>> } >>>> >>>> >>>> Version: Eclipse Persistence Services - 1.0.1 (Build 20080905) >>>> GF: GlassFish v3 Prelude (build b28f) >>>> >>>> / >>>> >> > |
|
|
Re: EntityManager lookup difference between GF V2 and V3For Eclipselink to understand the property should be called
"javax.persistence.nonJtaDataSource" ----- Original Message ----- From: "Girish Kumar Balachandran" <Girish.Balachandran@...> To: <persistence@...> Cc: "Nam Nguyen" <Nam.Nguyen@...> Sent: Friday, September 25, 2009 4:18 PM Subject: Re: EntityManager lookup difference between GF V2 and V3 > We manage our own EMs and do not depend on the container. BTW, the > difference between V2 and V3 usage in ours is, in V2 we did not use > eclipse link in V3 we are also trying out eclipse link. Apologies for not > mentioning it. So, would that be a reason why it is working for us in V2? > =Girish > > Marina Vatkina wrote: >> Mitesh, doesn't transaction-type="RESOURCE_LOCAL allow >> non-jta-data-source? >> >> thanks, >> -marina >> >> Mitesh Meswani wrote: >>> I am surprised that it worked in V2. You should be specifying >>> jta-data-source instead of non-jta-data-source in persitence.xml. >>> Somethig like as follows >>> / <persistence-unit name="*org.webonweb.runtime.impl.repository.db*" >>> transaction-type="RESOURCE_LOCAL"> >>> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> >>> >>> <non-jta-data-source>*jdbc/webonweb/repository*</non-jta-data-source> >>> //<jta-data-source>*jdbc/webonweb/repository*</jta-data-source>/ >>> >>> Thanks, >>> Mitesh >>> >>> Girish Kumar Balachandran wrote: >>> >>>> Hi There, >>>> We are trying out GF v3 for zembly.com and I am seeing following >>>> exception in obtaining EntityManager for EntityManagerFactory (em = >>>> emf.createEntityManager();): >>>> / >>>> Caused by: Exception [EclipseLink-4021] (Eclipse Persistence Services - >>>> 1.0.1 (Build 20080905)): >>>> org.eclipse.persistence.exceptions.DatabaseException >>>> Exception Description: Unable to acquire a connection from driver >>>> [null], user [null] and URL [null]. Verify that you have set the >>>> expected driver class and URL. Check your login, persistence.xml or >>>> sessions.xml resource. The jdbc.driver property should be set to a >>>> class that is compatible with your database platform >>>> at >>>> org.eclipse.persistence.exceptions.DatabaseException.unableToAcquireConnectionFromDriverException(DatabaseException.java:365) >>>> at >>>> org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:90)/ >>>> >>>> Things work perfect with GF V2/2.1 but, V3 does not seem to work. Am I >>>> supposed to do something more than the following? >>>> >>>> Any tips would be much appreciated. >>>> >>>> Thanks, >>>> =Girish >>>> >>>> These are the configuration I have: >>>> * >>>> System servlet has these 2 annotations reg PU:* >>>> >>>> /@PersistenceUnits( >>>> { >>>> @PersistenceUnit(name = >>>> "*webonweb/repositoryEntityManagerFactory*", >>>> unitName = >>>> "*org.webonweb.runtime.impl.repository.db*"), >>>> @PersistenceUnit(name = >>>> "*webonweb/readOnlyRepositoryEntityManagerFactory*", >>>> unitName = >>>> "*org.webonweb.runtime.impl.repository.db.readonly*") >>>> } >>>> )/ >>>> >>>> >>>> *Persistence.xml has (use introspection to discover all entities):* >>>> >>>> / <persistence-unit name="*org.webonweb.runtime.impl.repository.db*" >>>> transaction-type="RESOURCE_LOCAL"> >>>> >>>> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> >>>> >>>> <non-jta-data-source>*jdbc/webonweb/repository*</non-jta-data-source> >>>> <properties> >>>> <!-- <property name="toplink.logging.level" value="FINE"/> --> >>>> <!-- property name="toplink.logging.logger" >>>> value="JavaLogger"/ --> >>>> <!-- END JPA cache control properties --> >>>> <property name="eclipselink.cache.shared.default" value="true"/> >>>> <property name="eclipselink.logging.level" value="OFF"/> >>>> </properties> >>>> </persistence-unit> >>>> <persistence-unit >>>> name="*org.webonweb.runtime.impl.repository.db.readonly*" >>>> transaction-type="RESOURCE_LOCAL"> >>>> >>>> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> >>>> >>>> <non-jta-data-source>*jdbc/webonweb/readonlyrepository*</non-jta-data-source> >>>> <properties> >>>> <property name="eclipselink.cache.shared.default" value="true"/> >>>> <property name="eclipselink.logging.level" value="OFF"/> >>>> </properties> >>>> </persistence-unit> >>>> / >>>> *EMF was obtained by (got EMF with out any exception):* >>>> >>>> /protected EntityManagerFactory createEntityManagerFactory() throws >>>> RepositoryException { >>>> try { >>>> InitialContext ic = new InitialContext(); >>>> return (EntityManagerFactory) >>>> ic.lookup("*java:comp/env/webonweb/repositoryEntityManagerFactory*"); >>>> } catch (NamingException ne) { >>>> throw new RepositoryException(ne); >>>> } >>>> } >>>> protected EntityManagerFactory >>>> createReadOnlyEntityManagerFactory() throws RepositoryException { >>>> try { >>>> InitialContext ic = new InitialContext(); >>>> return (EntityManagerFactory) >>>> ic.lookup("*java:comp/env/webonweb/readOnlyRepositoryEntityManagerFactory*"); >>>> } catch (NamingException ne) { >>>> throw new RepositoryException(ne); >>>> } >>>> }/ >>>> >>>> *Made sure that the data source is getting looked up correctly by the >>>> following code - hence not a config problem:* >>>> >>>> /private Connection getConnection() throws RepositoryException, >>>> SQLException { >>>> try { >>>> InitialContext ic = new InitialContext(); >>>> DataSource sd = (DataSource) >>>> ic.lookup("*java:comp/env/jdbc/webonweb/repository*"); >>>> return sd.getConnection(); >>>> } catch (NamingException ne) { >>>> throw new RepositoryException(ne); >>>> } >>>> } >>>> >>>> >>>> Version: Eclipse Persistence Services - 1.0.1 (Build 20080905) >>>> GF: GlassFish v3 Prelude (build b28f) >>>> >>>> / >>>> >> > |
|
|
Re: EntityManager lookup difference between GF V2 and V3<persistence-unit name="org.webonweb.runtime.impl.repository.db" transaction-type="RESOURCE_LOCAL"> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> <non-jta-data-source>jdbc/webonweb/repository</non-jta-data-source> <properties> <property name="eclipselink.cache.shared.default" value="true"/> <property name="eclipselink.logging.level" value="OFF"/> <property name="javax.persistence.nonJtaDataSource" value="jdbc/webonweb/repository"/> </properties> </persistence-unit> Curious, is this a by design for V3 and later? Or is this a WIP? We would not use a JTA data source as we would like to use or own transactions. What is the best way to do this in V3 then? This solution feels like a un-supported hidden feature. Thanks, =Girish Andrei Ilitchev wrote: For Eclipselink to understand the property should be called "javax.persistence.nonJtaDataSource" |
| Free embeddable forum powered by Nabble | Forum Help |