users@glassfish.java.net

Glassfish 2.1: Classloading Issue with separate Entity JAR

From: Florian Probst <flo_at_probstl.de>
Date: Wed, 18 May 2011 09:50:17 +0200

Hello community,

we're having problems deploying our EAR file on Glassfish 2.1. The EAR file
contains a JAR file with session beans etc and a JAR file with all needed
Entity classes inside. The persistence.xml resides in the ejb JAR file and
references the JAR file with the pojos:

<?xml version="1.0" encoding="UTF-8"?>
<persistence>
<persistence-unit name="ATG" transaction-type="JTA">
<provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>
<jta-data-source>jdbc/atg</jta-data-source>
<jar-file>DE_AtgEnterpriseData-${project.version}.jar</jar-file>
</persistence-unit>
</persistence>

We configured the logging to fine and there is the following log entry
relating to the persistence.xml which means that the JAR file with the
entities is correctly referenced:

PersistenceInfo for this pud is :
<persistence-unit>
<PURoot>file:/C:/Program%20Files/glassfish-v2.1/domains/cargo/atg-ws/applications/j2ee-apps/DE_AtgEnterpriseArchive-1.0.0-SNAPSHOT/DE_AtgEnterpriseLogic-1.0.0-SNAPSHOT_jar/</PURoot>
<name>ATG</name>
<provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>
<transaction-type>JTA</transaction-type>
<jta-data-source>com.sun.gjc.spi.jdbc40.DataSource40_at_12eec91
</jta-data-source>
<non-jta-data-source>com.sun.gjc.spi.jdbc40.DataSource40_at_1ad5eab
</non-jta-data-source>
<jar-file>file:/C:/Program%20Files/glassfish-v2.1/domains/cargo/atg-ws/applications/j2ee-apps/DE_AtgEnterpriseArchive-1.0.0-SNAPSHOT/DE_AtgEnterpriseData-1.0.0-SNAPSHOT.jar</jar-file>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>{}</properties>
<class-loader>EJBClassLoader :
urlSet = [URLEntry :
file:/C:/Program%20Files/glassfish-v2.1/domains/cargo/atg-ws/applications/j2ee-apps/DE_AtgEnterpriseArchive-1.0.0-SNAPSHOT/DE_AtgEnterpriseLogic-1.0.0-SNAPSHOT_jar/,
URLEntry :
file:/C:/Program%20Files/glassfish-v2.1/domains/cargo/atg-ws/generated/ejb/j2ee-apps/DE_AtgEnterpriseArchive-1.0.0-SNAPSHOT/]
doneCalled = false
 Parent -> EJBClassLoader :
urlSet = []
doneCalled = false
 Parent -> java.net.URLClassLoader_at_18b3e62
</class-loader>
</persistence-unit>
|#]

Nevertheless there is a ClassNotFoundException when reading the Entities:

Caused by: Exception [TOPLINK-30007] (Oracle TopLink Essentials - 2.1 (Build
b60e-fcs (12/23/2008))):
oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while loading class:
com.desoft.atg.enterprise.entity.TDefect2pqm to check whether it implements
@Entity, @Embeddable, or @MappedSuperclass.
Internal Exception: java.lang.ClassNotFoundException:
com.desoft.atg.enterprise.entity.TDefect2pqm
at
oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException.exceptionLoadingClassWhileLookingForAnnotations(PersistenceUnitLoadingException.java:161)
at
oracle.toplink.essentials.ejb.cmp3.persistence.PersistenceUnitProcessor.loadClass(PersistenceUnitProcessor.java:265)
at
oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProcessor.processPersistenceUnitClasses(MetadataProcessor.java:413)
at
oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProcessor.processPersistenceUnitClasses(MetadataProcessor.java:369)
at
oracle.toplink.essentials.ejb.cmp3.persistence.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:292)
at
oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:608)
... 73 more

Is ist possible to separate the Session Beans and Entities? This is what wie
tried, but nothing works:
- Entity JAR file moved to APP-INF/lib folder
- Added META-INF Classpath for Ejb JAR referencing Entity JAR file
- Define all Classes in persistence.xml

Can somebody pelase help us on this issue?

Regards,
Florian