Return-Path: Delivered-To: apmail-camel-users-archive@www.apache.org Received: (qmail 95779 invoked from network); 26 Oct 2009 12:01:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 26 Oct 2009 12:01:06 -0000 Received: (qmail 67085 invoked by uid 500); 26 Oct 2009 12:01:06 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 67066 invoked by uid 500); 26 Oct 2009 12:01:06 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 67056 invoked by uid 99); 26 Oct 2009 12:01:06 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Oct 2009 12:01:06 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Oct 2009 12:00:55 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1N2OFW-0004Wi-ND for users@camel.apache.org; Mon, 26 Oct 2009 05:00:34 -0700 Message-ID: <26058442.post@talk.nabble.com> Date: Mon, 26 Oct 2009 05:00:34 -0700 (PDT) From: B_A To: users@camel.apache.org Subject: Re: JPA component in a JEE5 environment: EntityManagerFactory from JNDI In-Reply-To: <5380c69c0910260217vf7077d8m96054da14e9a7181@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Nabble-From: bernd.altmiks@steria-mummert.de References: <25219979.post@talk.nabble.com> <5380c69c0908310451h33a7f42cl7941d63c382e6e9@mail.gmail.com> <25275422.post@talk.nabble.com> <26056419.post@talk.nabble.com> <5380c69c0910260217vf7077d8m96054da14e9a7181@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org Claus Ibsen-2 wrote: >=20 > On Mon, Oct 26, 2009 at 10:13 AM, BAltmiks > wrote: >> >> >> >> BAltmiks wrote: >>> >>> Hi Claus, >>> >>> this is what the Oracle-Support says. I will try these. >>> >>> >>> Hello Bernd, >>> >>> I tried calling you regarding the issue, however couldn't reach. >>> >>> As per the issue I understand that you are using trying to lookup the >>> Entity Manager instance and you are trying to use Entity Manager >>> Factory, but you do not wish to use injection of .@PersistenceContext. >>> >>> Please let me know if you are using any JPA provider (e.g. kodo, >>> hibernate etc). >>> >>> In JEE the EntityManager or EntityManagerFactory can either be looked >>> up in JNDI, or injected into a SessionBean. To look up the >>> EntityManager in JNDI it must be published in JNDI such as through a >>> in a SessionBean's ejb-jar.xml file. To >>> inject an EntityManager or EntityManagerFactory the >>> annotation .@PersistenceContext or .@PersistenceUnit are used. >>> >>> For your reference I am adding both the options (annotation / non- >>> annota) >>> >>> Example SessionBean ejb-jar.xml file with persistence context >>> >>> >>> >> xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance" >>> xsi:schemaLocation=3D"http://java.sun.com/xml/ns/javaee >>> http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" >>> version=3D"3.0"> >>> >>> >>> EmployeeService >>> org.acme.EmployeeService >>> org.acme.EmployeeServiceBean >>> Stateless >>> >>> persistence/acme/entity-manager>> persistence-context-ref-name> >>> acme >>> >>> >>> persistence/acme/factory>> ref-name> >>> acme >>> >>> >>> >>> >>> >>> Example of looking up an EntityManager in JNDI >>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >>> >>> InitialContext context =3D new InitialContext(); >>> EntityManager entityManager =3D (EntityManager)context.lookup("java:com= p/ >>> env/persistence/acme/entity-manager"); >>> ... >>> >>> Example of looking up an EntityManagerFactory in JNDI >>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D >>> >>> InitialContext context =3D new InitialContext(); >>> EntityManagerFactory factory =3D (EntityManagerFactory)context.lookup >>> ("java:comp/env/persistence/acme/factory"); >>> ... >>> >>> Example of injecting an EntityManager and EntityManagerFactory >>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >>> >>> .@Stateless(name=3D"EmployeeService", mappedName=3D"acme/EmployeeServic= e") >>> .@Remote(EmployeeService.class) >>> public class EmployeeServiceBean implements EmployeeService { >>> >>> .@PersistenceContext(unitName=3D"acme") >>> private EntityManager entityManager; >>> >>> .@PersistenceUnit(unitName=3D"acme") >>> private EntityManagerFactory factory; >>> ... >>> } >>> >>> Please feel free to get back to me in case of any doubt or query >>> regarding the same. >>> >>> >>> Regards, >>> Saumajit Das >>> >>> >>> >>> >>> >>>> >>> Claus Ibsen-2 wrote: >>>> >>>>>Hi >>>>> >>>>>That is the same s*** with the J2ee servers and the JNDI lookup. Its >>>>>painful when it does not work and you need to setup all kind >>>>>of indirections in various deployment descriptors both standard j2ee >>>>>related and server specific. >>>>> >>>>>I will try googling and look at WebLogic documentation as its a pure >>>>>WebLogic + Spring J2ee lookup thingy. >>>> >>>> >>>> >>>> On Mon, Aug 31, 2009 at 10:31 AM, >>>> BAltmiks wrote: >>>>> >>>>> - Camel 2.0M3 >>>>> - Camel-JPA 2.0M3 >>>>> - Weblogic 10 >>>>> - Hibernate-Core 3.3.0.SP1 >>>>> - Hibernate-EntityManager 3.4.0.GA >>>>> - Configuration in Spring XML >>>>> >>>>> >>>>> Hi, >>>>> >>>>> I tried to make use of the jpa component. But I have problems to get >>>>> an >>>>> EntityManagerFactory from JNDI on Weblogic 10. As described in the >>>>> http://static.springsource.org/spring/docs/2.5.x/reference/orm.html#o= rm-jpa >>>>> Spring JPA Documentation =C2=A0I do a JNDI-Lookup. persistence-unit-r= ef >>>>> entries >>>>> are defined in the Java EE deployment descriptor (ejb-jar.xml). >>>>> >>>>> The Exception is: >>>>> >>>>> javax.naming.NameNotFoundException: Unable to resolve >>>>> 'TMD_PERSISTENCE'. >>>>> Resolved ''; remaining name 'TMD_PERSISTENCE' >>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0at >>>>> weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(Basic= NamingNode.java:1138) >>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0at >>>>> weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.jav= a:251) >>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0at >>>>> weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.j= ava:171) >>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0at >>>>> weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:20= 5) >>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0at >>>>> weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.j= ava:254) >>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0at >>>>> weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:367) >>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0at javax.naming.InitialContext.lookup(Init= ialContext.java:351) >>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0at >>>>> org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java= :155) >>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0at >>>>> org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:88) >>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0at >>>>> org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:153) >>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0at >>>>> org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178) >>>>> >>>>> Can anybody give me a hint what i am doing wrong? >>>>> >>>>> Thanks, >>>>> Bernd Altmiks >>>>> >>>>> My Camel-Context: >>>>> ... >>>>> >>>>> >>>>> >>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 >>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 >>>>> >>>>> >>>>> >>>> class=3D"org.springframework.transaction.jta.WebLogicJtaTransactionMa= nager"/> >>>>> ... >>>>> >>>>> >>>>> My ejb-jar.xml >>>>> >>>>> >>>>> >>>>> >>>> xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance" >>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0xsi:schemaLocation=3D"http://java.sun.com/= xml/ns/javaee >>>>> http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" >>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0version=3D"3.0"> >>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 >>>>> >>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 >>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0ITMDClientDAO >>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0tmd.al.dao.TMDClientDAO >>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0Stateless >>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 >>>>> >>>>> =C2=A0TMD_PERSISTENCE >>>>> >>>>> =C2=A0TMD_PERSISTENCE >>>>> >>>>> =C2=A0TMD_PERSISTENCE >>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 >>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 >>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 >>>>> >>>>> >>>>> >>>>> My persistence.xml >>>>> >>>>> >>>>> >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0xmlns:xsi=3D"http://www.w3.org/2001/XMLSch= ema-instance" >>>>> version=3D"1.0" >>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0xsi:schemaLocation=3D"http://java.sun.com/= xml/ns/persistence >>>>> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"> >>>>> =C2=A0 >>>>> =C2=A0 =C2=A0org.hibernate.ejb.HibernatePersistence >>>>> >>>>> com.mummert.tributum.tbpersistence.TributumDataSourc= e >>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0tmd.al.entity.TMDMessage >>>>> =C2=A0 =C2=A0 >>>>> =C2=A0 =C2=A0 =C2=A0>>>> value=3D"org.hibernate.dialect.Oracle10gDialect"/> >>>>> =C2=A0 =C2=A0 =C2=A0>>>> value=3D"org.hibernate.transaction.WeblogicTransactionManagerLookup" = /> >>>>> =C2=A0 =C2=A0 =C2=A0 >>>>> =C2=A0 =C2=A0 =C2=A0 >>>>> =C2=A0 =C2=A0 =C2=A0 >>>>> =C2=A0 =C2=A0 =C2=A0 >>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 >>>> name=3D"hibernate.jndi.weblogic.jndi.replicateBindings" >>>>> value=3D"false" /> >>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0>>>> value=3D"org.hibernate.hql.classic.ClassicQueryTranslatorFactory"/> >>>>> =C2=A0 =C2=A0 =C2=A0>>>> value=3D"false"/> >>>>> =C2=A0 =C2=A0 >>>>> =C2=A0 >>>>> >>>>> >>>>> >>>>> -- >>>>> View this message in context: >>>>> http://www.nabble.com/JPA-component-in-a-JEE5-environment%3A-EntityMa= nagerFactory-from-JNDI-tp25219979p25219979.html >>>>> Sent from the Camel - Users mailing list archive at Nabble.com. >>>>> >>>>> >>>> >>>> >>>> >>>> -- >>>> Claus Ibsen >>>> Apache Camel Committer >>>> >>>> Open Source Integration: http://fusesource.com >>>> Blog: http://davsclaus.blogspot.com/ >>>> Twitter: http://twitter.com/davsclaus >>>> >>>> >>> >>> >> >> Doesn't work on Weblogic. There is no way to get the EntityManager from >> JNDI. Here is the answer from the Oracle-Support: >> >> "According the EJB3 specification, you need to lookup the entity from th= e >> same container (from any servlet or session bean running on that >> container)." >> >=20 > And how do Oracle Support envision you should lookup an Entity? > Using JNDI? And if so how do you do that? How do you configure / setup > this? > And how do you get the Entity registered in the first place? >=20 >=20 >=20 >> >> -- >> View this message in context: >> http://www.nabble.com/JPA-component-in-a-JEE5-environment%3A-EntityManag= erFactory-from-JNDI-tp25219979p26056419.html >> Sent from the Camel - Users mailing list archive at Nabble.com. >> >> >=20 >=20 >=20 > --=20 > Claus Ibsen > Apache Camel Committer >=20 > Author of Camel in Action: http://www.manning.com/ibsen/ > Open Source Integration: http://fusesource.com > Blog: http://davsclaus.blogspot.com/ > Twitter: http://twitter.com/davsclaus >=20 >=20 >And how do Oracle Support envision you should lookup an Entity? >Using JNDI? And if so how do you do that? How do you configure / setup this? >And how do you get the Entity registered in the first place? Sorry Claus my mistake when I wrote this Message. I mean EntityManagerFactory and not Entity. I=20 http://www.nabble.com/file/p26058442/entitymanagerfactorylookup.zip entitymanagerfactorylookup.zip=20 http://www.nabble.com/file/p26058442/entitymanagerfactorylookup.zip entitymanagerfactorylookup.zip=20 have corrected my Message.=20 I have sent the Oracle-Support an example Testcase (find it attached) so that they can see what i=20 want to do. I my case lookup the EntityManagerFactory from an "client". An POJO like=20 Camel/Spring. The answer I got was that it is not possible on Weblogic 10.0 if you are not=20 "inside" an Session Bean or Servlet. At the Moment, as a workaround, I use an Stateless Session Bean where the EntityManager (not the=20 EntityManagerFactory) gets injected to persist my Entity with Camel. =20 I would be thankfully if you have any further suggestions. Regards, Bernd --=20 View this message in context: http://www.nabble.com/JPA-component-in-a-JEE5= -environment%3A-EntityManagerFactory-from-JNDI-tp25219979p26058442.html Sent from the Camel - Users mailing list archive at Nabble.com.