You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by mrLittle <mr...@gmail.com> on 2014/02/11 14:44:07 UTC
Specify JPA properties for embeddable EJBContainer
Hi,
I'm using an embeddable EJBContainer (.createEJBContainer()) with a
persicence.xml file to configure JPA for managing Oracle datasource.
I'm not able to use @PersistenceContext to inject my entityManager (got
null).
Following a suggestion of Romain
(http://openejb.979440.n4.nabble.com/Warning-persistence-unit-configuration-td4667381.html)
I've tried to to set my properties directly into my EJBContainer but it
didn't work.
I'm quite sure I'm doing wrong somwhere, so the question is, how can I set
my jpa properties into the embeddable container? By doing it that way, is
the persistence.xml file still required?
Many Thanks
--
View this message in context: http://openejb.979440.n4.nabble.com/Specify-JPA-properties-for-embeddable-EJBContainer-tp4667656.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Specify JPA properties for embeddable EJBContainer
Posted by mrLittle <mr...@gmail.com>.
But it seems not to be enough for Entitymanager injection, doesn't it?
ty
--
View this message in context: http://openejb.979440.n4.nabble.com/Specify-JPA-properties-for-embeddable-EJBContainer-tp4667656p4667660.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Specify JPA properties for embeddable EJBContainer
Posted by Romain Manni-Bucau <rm...@gmail.com>.
please share a project with a unit test showing the expected behavior
with mvn clean test. It will avoid a lot of mail exchange (you can try
openejb:Resource/jndi/name as jndi name instead of short name)
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau
2014-02-11 16:20 GMT+01:00 mrLittle <mr...@gmail.com>:
> Yeah exactly, I've forgot to edit my post :P
>
> Anyway, using @PersistenceUnit I get the same error reported in my previous
> post:
> 979 STGATE TRACE [main] openjpa.jdbc.JDBC - Initial connection
> autoCommit: true, holdability: 1, TransactionIsolation: 2
> 979 STGATE INFO [main] openjpa.jdbc.JDBC - Connected to HSQL Database
> Engine version 2.2 using JDBC driver HSQL Database Engine Driver version
> 2.3.0.
> ....
> and, of course, the first time I try to use my entitymanager:
> fatal general error> org.apache.openjpa.persistence.PersistenceException:
> user lacks privilege or object not found
>
> so the question still remains,,how can I configure my oracle datasource into
> embeddable openejb?
>
> Ty
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/Specify-JPA-properties-for-embeddable-EJBContainer-tp4667656p4667671.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Specify JPA properties for embeddable EJBContainer
Posted by mrLittle <mr...@gmail.com>.
Yeah exactly, I've forgot to edit my post :P
Anyway, using @PersistenceUnit I get the same error reported in my previous
post:
979 STGATE TRACE [main] openjpa.jdbc.JDBC - Initial connection
autoCommit: true, holdability: 1, TransactionIsolation: 2
979 STGATE INFO [main] openjpa.jdbc.JDBC - Connected to HSQL Database
Engine version 2.2 using JDBC driver HSQL Database Engine Driver version
2.3.0.
....
and, of course, the first time I try to use my entitymanager:
fatal general error> org.apache.openjpa.persistence.PersistenceException:
user lacks privilege or object not found
so the question still remains,,how can I configure my oracle datasource into
embeddable openejb?
Ty
--
View this message in context: http://openejb.979440.n4.nabble.com/Specify-JPA-properties-for-embeddable-EJBContainer-tp4667656p4667671.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Specify JPA properties for embeddable EJBContainer
Posted by Romain Manni-Bucau <rm...@gmail.com>.
@PersistenceUnit ;)
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau
2014-02-11 15:44 GMT+01:00 mrLittle <mr...@gmail.com>:
> Ok, looking at
> now I know I won't be able to inject entityManager using a resource_local
> PU.
> So I'm triyng to inject the entityManagerFactory using @PersistenceContext
> but I get null as well.
> In my log I see:
>
> 1 STGATE TRACE [main] openjpa.Runtime -
> org.apache.openjpa.persistence.PersistenceProviderImpl@a8198c creating
> container org.apache.openjpa.persistence.EntityManagerFactoryImpl@25753d for
> PU STGATE.
> 11-feb-2014 15.41.13
> org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory
> createDelegate
> INFO: PersistenceUnit(name=STGATE,
> provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider
> time 1238ms
>
> but
> @PersistenceContext(unitName = "STGATE")
> private EntityManagerFactory emf;
>
> return a null emf.
>
> Ty
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/Specify-JPA-properties-for-embeddable-EJBContainer-tp4667656p4667665.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Specify JPA properties for embeddable EJBContainer
Posted by mrLittle <mr...@gmail.com>.
Ok, looking at
now I know I won't be able to inject entityManager using a resource_local
PU.
So I'm triyng to inject the entityManagerFactory using @PersistenceContext
but I get null as well.
In my log I see:
1 STGATE TRACE [main] openjpa.Runtime -
org.apache.openjpa.persistence.PersistenceProviderImpl@a8198c creating
container org.apache.openjpa.persistence.EntityManagerFactoryImpl@25753d for
PU STGATE.
11-feb-2014 15.41.13
org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory
createDelegate
INFO: PersistenceUnit(name=STGATE,
provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider
time 1238ms
but
@PersistenceContext(unitName = "STGATE")
private EntityManagerFactory emf;
return a null emf.
Ty
--
View this message in context: http://openejb.979440.n4.nabble.com/Specify-JPA-properties-for-embeddable-EJBContainer-tp4667656p4667665.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Specify JPA properties for embeddable EJBContainer
Posted by Romain Manni-Bucau <rm...@gmail.com>.
yes persistence.xml is required to specify datasource jndi name +
persistence unit + transaction mode
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau
2014-02-11 14:44 GMT+01:00 mrLittle <mr...@gmail.com>:
> Hi,
> I'm using an embeddable EJBContainer (.createEJBContainer()) with a
> persicence.xml file to configure JPA for managing Oracle datasource.
> I'm not able to use @PersistenceContext to inject my entityManager (got
> null).
> Following a suggestion of Romain
> (http://openejb.979440.n4.nabble.com/Warning-persistence-unit-configuration-td4667381.html)
> I've tried to to set my properties directly into my EJBContainer but it
> didn't work.
> I'm quite sure I'm doing wrong somwhere, so the question is, how can I set
> my jpa properties into the embeddable container? By doing it that way, is
> the persistence.xml file still required?
>
> Many Thanks
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/Specify-JPA-properties-for-embeddable-EJBContainer-tp4667656.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.