tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject Override PersistenceContext
Date Mon, 16 Feb 2009 13:13:52 GMT
Hi @all,

I´d like to override the settings for the PersistenceContext, but somehow it does not work.
My Scenario is as follows: I´ve got a REFERENCED JAR and my local project. The referenced
jar contains some stateless services, with an annotated EntityManager pointing to the default
PersistenceContext without declaring a unitName.

Then I´ve got my project, which also has it´s own persistence.xml and some services. As
there are 2 persistence-units-defintions now, the services from the referenced as well as
those from my local project fail to start, because injection does not work anymore. So far
so good! So I decided to override the persistenceUnit from the services in the referencedJar
and point them to a specific persistence-unit-name.

This is my business class from the referenced jar (where CustomerManager is it´s local interface
annotated with @Local):
package company;

public class CustomerManagerImpl implements CustomerManager {

        private EntityManager entityManager;


Now I included an ejb-jar.xml in my /classes/META-INF directory within my local project and
redefined the EntityManager as follows:

<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns=""
                metadata-complete="true" >

If I put anything wrong in this ejb-jar.xml I always receive an error. So I assume, that the
ejb-jar is interpreted correctly, but anyways I receive an error when booting openEJB.

ERROR - FAIL ... CustomerManagerImpl:   The persistence unit "" does not exist.  Update the
"entityManager" PersistenceContext ref to one of the avail
able units [CleoServicePU, IisTestPU] or declare the unit in a persistence.xml like the following:<persistence
stence" version="1.0"><persistence-unit name=""><jta-data-source>java:openejb/Resource/myDataSource</jta-data-source><non-jta-data-source>java:openejb
name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true

Did I miss anything?


View raw message