Hi,
I'm using TomEE 1.1.0-SNAPSHOT version from the 29/08/2012.
I have an EAR folder which I have deployed in the apps/ folder. The EAR
consists of 2 jar libraries, 1 ejb module and 2 war application.
For the security and authentication of the users I want to use a DB so I
have configured TomEE in this way.
in tomee.xml I have my 2 datasources
<Resource id="MyDS" type="DataSource">
JdbcDriver org.postgresql.Driver
JdbcUrl jdbc:postgresql://127.0.0.1:5432/test
UserName test
# For Production password should be a ciphered value Static3DES codec.
Check OpenEJB cipher
Password test1
JtaManaged true
</Resource>
<Resource id="MyUnmanagedDS" type="DataSource">
JdbcDriver org.postgresql.Driver
JdbcUrl jdbc:postgresql://127.0.0.1:5432/test
UserName test
# For Production password should be a ciphered value Static3DES codec.
Check OpenEJB cipher
Password test1
JtaManaged false
</Resource>
in server.xml I have
<Realm className="org.apache.catalina.realm.DataSourceRealm"
localDataSource="true"
dataSourceName="MyDS"
userTable="VUser" userNameCol="vname" userCredCol="vpassword"
userRoleTable="VRole" roleNameCol="vrole"
digest="MD5"/>
I get this error for all the EAO classes which uses the EntityManager, as
an example:
SEVERE: FAIL ... PayoutStructureEAO: The reference
@PersistenceContext(name="em", unitName="gamgamEJB") cannot be resolved as
there are 2 units with the same name. Update your unitName to one of the
following:gamgamEJB 500754579
gamgamEJB 811645777
All the EAO beans extends AbstractEAO which contains the following
public abstract class AbstractEAO {
@PersistenceContext(unitName = "gamgamEJB")
protected EntityManager em;
}
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="gamgamEJB" transaction-type="JTA">
<!-- Enable Hibernate provider. Add dependency pom.xml -->
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>MyDS</jta-data-source>
<non-jta-data-source>MyUnmanagedDS</non-jta-data-source>
<class>...</class>
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.PostgreSQLDialect" />
<property name="hibernate.hbm2ddl.auto" value="update" />
<!-- property name="hibernate.hbm2ddl.auto" value="create-drop"/ -->
<!-- enable sql log, not for production -->
<property name="hibernate.show_sql" value="false"/>
</properties>
</persistence-unit>
</persistence>
I'm using hibernate as persistence provider and I have followed the guide
from the TomEE website.
About a year ago I did managed to make it run on Tomcat + OpenEJB, so I
believe i'm actually missing something in the configuration.
Thanks in advance for any help,
Luca
--
*Luca Merolla*
Management, Business & Technology Consultant
<http://maps.google.com/maps?q=&hl=en> *Mobile:* +393774569974
*http://nl.linkedin.com/in/lucamerolla*
*Blog <http://lucamerolla.wordpress.com>*
Merolla Consulting Limited