1

We're running an EAR on WAS 8.5, and every one of our DAOs are duplicated 31 times. Noticing our persistence.xml has 30 JNDI datasources, I tested reducing the number, and indeed the duplicate count decreases.

But I've tried removing every superfluous line in succession, and I still get the duplicates. Removing the last line gives me a NestedJarException though.

   <persistence-unit name="unitTest"
          transaction-type="JTA">    
          <jta-data-source>jdbc/Testing/Ds</jta-data-source>
          <mapping-file>META-INF/default-mappings.xml</mapping-file>
          <exclude-unlisted-classes>false</exclude-unlisted-classes>
   </persistence-unit>

Does anyone know of anything else that might cause my EJB classes to be duplicated for every persistence unit?

Regards

djb
  • 1,635
  • 3
  • 26
  • 49

1 Answers1

1

if you check JPA 2.0 specification page 76 item 3.2 "Entity Instance’s Life Cycle " as you see below:

3.2 Entity Instance’s Life Cycle This section describes the EntityManager operations for managing an entity instance’s lifecycle.

An entity instance can be characterized as being new, managed, detached, or removed.

• A new entity instance has no persistent identity, and is not yet associated with a persistence context.

• A managed entity instance is an instance with a persistent identity that is currently associated with a persistence context.

• A detached entity instance is an instance with a persistent identity that is not (or no longer) associated with a persistence context.

• A removed entity instance is an instance with a persistent identity, associated with a persis- tence context, that will be removed from the database upon transaction commit.

Than I would imagine your situation means you have 30 jpa persistent objects each one mapped for 1 persistent context(persistence identity) pointing to each one of the databases and you probably have 1 detached and/or new one with no persistent identity.

This happens because of how the specification determines the Entity instance life cycle should be implemented.

halfer
  • 19,824
  • 17
  • 99
  • 186
groo
  • 4,213
  • 6
  • 45
  • 69
  • This regards managing an entity instance. Unfortunately, in my case, it's EJBs that are being duplicated. EJBs are not persistent objects - when they get used (e.g. to query the DB), that will cause an EntityManagerFactory to supply an EntityManager, which will be used as required, and that is when the above would be relevant. – djb Apr 29 '13 at 09:53