Hi Claus,

thank your for your help!

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  
<persistence-context-ref> 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

<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd";
version="3.0">
<enterprise-beans>
<session>
<ejb-name>EmployeeService</ejb-name>
<business-remote>org.acme.EmployeeService</business-remote>
<ejb-class>org.acme.EmployeeServiceBean</ejb-class>
<session-type>Stateless</session-type>
<persistence-context-ref>
<persistence-context-ref-name>persistence/acme/entity-manager</ 
persistence-context-ref-name>
<persistence-unit-name>acme</persistence-unit-name>
</persistence-context-ref>
<persistence-unit-ref>
<persistence-unit-ref-name>persistence/acme/factory</persistence-unit- 
ref-name>
<persistence-unit-name>acme</persistence-unit-name>
</persistence-unit-ref>
</session>
</enterprise-beans>
</ejb-jar>

Example of looking up an EntityManager in JNDI
===============================================

InitialContext context = new InitialContext();
EntityManager entityManager = (EntityManager)context.lookup("java:comp/ 
env/persistence/acme/entity-manager");
...

Example of looking up an EntityManagerFactory in JNDI
=====================================================

InitialContext context = new InitialContext();
EntityManagerFactory factory = (EntityManagerFactory)context.lookup 
("java:comp/env/persistence/acme/factory");
...

Example of injecting an EntityManager and EntityManagerFactory
===============================================================

....@stateless(name="EmployeeService", mappedName="acme/EmployeeService")
....@remote(EmployeeService.class)
public class EmployeeServiceBean implements EmployeeService {

....@persistencecontext(unitName="acme")
private EntityManager entityManager;

....@persistenceunit(unitName="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<[email protected]> 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#orm-jpa
>> Spring JPA Documentation  I do a JNDI-Lookup. persistence-unit-ref
>> 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'
>>        at
>> weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1138)
>>        at
>> weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:251)
>>        at
>> weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:171)
>>        at
>> weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:205)
>>        at
>> weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.java:254)
>>        at
>> weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:367)
>>        at javax.naming.InitialContext.lookup(InitialContext.java:351)
>>        at
>> org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:155)
>>        at
>> org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:88)
>>        at
>> org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:153)
>>        at
>> 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:
>> ...
>> <jee:jndi-lookup id="eMFactory" jndi-name="TMD_PERSISTENCE"/>
>>
>> <bean id="jpa" class="org.apache.camel.component.jpa.JpaComponent">
>>        <property name="entityManagerFactory" ref="eMFactory" />
>>        <property name="transactionManager" ref="txManager" />
>> </bean>
>>
>> <bean id="txManager"
>> class="org.springframework.transaction.jta.WebLogicJtaTransactionManager"/>
>> ...
>>
>>
>> My ejb-jar.xml
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>>
>> <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee";
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>>        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
>> http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd";
>>        version="3.0">
>>        <enterprise-beans>
>>
>>                <session>
>>                        <ejb-name>ITMDClientDAO</ejb-name>
>>                        <ejb-class>tmd.al.dao.TMDClientDAO</ejb-class>
>>                        <session-type>Stateless</session-type>
>>                        <persistence-unit-ref>
>>                              
>>  <persistence-unit-ref-name>TMD_PERSISTENCE</persistence-unit-ref-name>
>>                              
>>  <persistence-unit-name>TMD_PERSISTENCE</persistence-unit-name>
>>                                <mapped-name>TMD_PERSISTENCE</mapped-name>
>>                        </persistence-unit-ref>
>>                </session>
>>        </enterprise-beans>
>> </ejb-jar>
>>
>>
>> My persistence.xml
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <persistence xmlns="http://java.sun.com/xml/ns/persistence";
>>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>> version="1.0"
>>        xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
>> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd";>
>>  <persistence-unit name="TMD_PERSISTENCE" transaction-type="JTA">
>>    <provider>org.hibernate.ejb.HibernatePersistence</provider>
>>
>> <jta-data-source>com.mummert.tributum.tbpersistence.TributumDataSource</jta-data-source>
>>        <class>tmd.al.entity.TMDMessage</class>
>>    <properties>
>>      <property name="hibernate.dialect"
>> value="org.hibernate.dialect.Oracle10gDialect"/>
>>      <property name="hibernate.transaction.manager_lookup_class"
>> value="org.hibernate.transaction.WeblogicTransactionManagerLookup" />
>>      <property name="hibernate.show_sql" value="false" />
>>      <property name="hibernate.format_sql" value="false" />
>>      <property name="hibernate.use_sql_comments" value="false"/>
>>      <property name="hibernate.generate_statistics" value="false" />
>>           <property name="hibernate.jndi.weblogic.jndi.replicateBindings"
>> value="false" />
>>            <property name="hibernate.query.factory_class"
>> value="org.hibernate.hql.classic.ClassicQueryTranslatorFactory"/>
>>      <property name="hibernate.cache.use_second_level_cache"
>> value="false"/>
>>    </properties>
>>  </persistence-unit>
>> </persistence>
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/JPA-component-in-a-JEE5-environment%3A-EntityManagerFactory-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
> 
> 

-- 
View this message in context: 
http://www.nabble.com/JPA-component-in-a-JEE5-environment%3A-EntityManagerFactory-from-JNDI-tp25219979p25275422.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to