Several Datasources??
konstt2000 Apr 6, 2009 4:44 PMHi,
I want to have several Datasources.
I've configured:
components.xml
<persistence:managed-persistence-context name="entityManager" auto-create="true" persistence-unit-jndi-name="java:/PruebasSeamEntityManagerFactory"/> <persistence:managed-persistence-context name="entityManagerBPM" auto-create="true" persistence-unit-jndi-name="java:/PruebasSeamJBPMEntityManagerFactory"/>
persistence.xml
<persistence-unit name="PruebasSeam"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <jta-data-source>java:/PruebasSeamDatasource</jta-data-source> <properties> <!-- <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/> --> <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9iDialect"/> <property name="hibernate.hbm2ddl.auto" value="update"/> <property name="hibernate.show_sql" value="true"/> <property name="hibernate.format_sql" value="true"/> <property name="jboss.entity.manager.factory.jndi.name" value="java:/PruebasSeamEntityManagerFactory"/> </properties> </persistence-unit> <persistence-unit name="PruebasSeamJBPM"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <jta-data-source>java:/PruebasSeamJBPMDatasource</jta-data-source> <properties> <!-- <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>--> <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9iDialect"/> <property name="hibernate.hbm2ddl.auto" value="update"/> <property name="hibernate.show_sql" value="true"/> <property name="hibernate.format_sql" value="true"/> <property name="jboss.entity.manager.factory.jndi.name" value="java:/PruebasSeamJBPMEntityManagerFactory"/> </properties> </persistence-unit>
and MyProject-ds.xml
How can I acceded several DataSources in a class??
I've tring:
@Stateless @Name("authenticator") public class Authenticator implements IAuthenticator { @PersistenceContext(name="entityManager") EntityManager entityManager; @PersistenceContext(name="entityManagerBPM") EntityManager entityManagerBPM;
The exception produced is:
16:30:58,213 WARN [ServiceController] Problem starting service jboss.j2ee:service=EJB3,module=PruebasSeam.jar java.lang.RuntimeException: Illegal @PersistenceUnit on javax.persistence.EntityManager com.prueba.sesion.Authenticator.entityManager :EMPTY STRING unitName and there is more than one scoped persistence unit at org.jboss.injection.PersistenceContextHandler.handleFieldAnnotations(PersistenceContextHandler.java:182) at org.jboss.injection.InjectionUtil.processFieldAnnotations(InjectionUtil.java:137) at org.jboss.injection.InjectionUtil.processAnnotations(InjectionUtil.java:174)