[jboss-user] [EJB 3.0] - Multiple Persistence Unit
go_rags
do-not-reply at jboss.com
Thu Sep 21 17:15:17 EDT 2006
Hi,
I am trying to access 2 different datasources in my EAR. We have a MySQL database for all the standard operations, i am now trying to access a few tables from a differnt datasource.
The primary tables are accessed without a persistenceUnit, by using theDefaultDS configured. (i.e. I did not provide a unitName while creating the EntityManager)
So I added a persistence.xml to the META-INF with the following lines assuming the new entities and bean will use the unit-name provided in the persistence.xml. I have one entity called T1 and a bean to access it.
| <?xml version="1.0" encoding="UTF-8"?>
| <persistence>
| <persistence-unit name="ragsDemo">
| <provider>org.hibernate.ejb.HibernatePersistence</provider>
| <class>com.rags.test.T1</class>
| <jta-data-source>java:/TestDS</jta-data-source>
| <properties>
| <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
| <!-- <property name="hibernate.hbm2ddl.auto" value="create-drop"/> -->
| <!-- <property name="hibernate.hbm2ddl.auto" value="update"/> -->
| </properties>
| </persistence-unit>
| </persistence>
|
In the bean code i am creating the Entity manager using the following lines
| @PersistenceContext(unitName="ragsDemo")
| EntityManager em;
|
But when I deploy I am getting the following error :
| --- MBeans waiting for other MBeans ---
| ObjectName: jboss.j2ee:service=EJB3,name=com.rags.test.T1AccessBean
| State: FAILED
| Reason: java.lang.RuntimeException: unable to find: java:/managedEntityFactories/ragsDemo
|
I am using JBoss 4.0.3 SP1, can somebody tell me where I am going wrong.
Thanks.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3973418#3973418
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3973418
More information about the jboss-user
mailing list