0
votes

I have a DAO that uses JPA with a non-JTA data source and RESOURCE_LOCAL transactions. All of my unit tests that exercise the DAO work perfectly (data is inserted and retrieved from the database).

When I deploy my EJB to my Weblogic 10.3.3 server, however, I get the following exception:

Caused by: java.lang.IllegalArgumentException: Unknown entity bean class: class com.foo.bar.CatalogEntity, please verify that this class has been marked with the @Entity annotation.
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.find(EntityManagerImpl.java:576)

My persistence.xml (in WEB-INF/classes/META-INF):

<?xml version="1.0" ?>
<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_1_0.xsd"
    version="1.0" xmlns="http://java.sun.com/xml/ns/persistence">
    <persistence-unit name="cmf-awe-service" transaction-type="RESOURCE_LOCAL">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <non-jta-data-source>MyDataSource</non-jta-data-source>
        <class>com.foo.bar.CatalogEntity</class>
        <properties>
            <property name="eclipselink.cache.shared.default" value="false"/>
            <property name="eclipselink.query-results-cache" value="false"/>
            <property name="eclipselink.target-server" value="WebLogic_10" />
            <property name="eclipselink.logging.level" value="FINEST" />
        </properties>
    </persistence-unit>
</persistence>

I have confirmed that the CatalogEntity class is in the WEB-INF/classes directory. Any ideas about why this works in unit tests but not when deployed to the application server?

1
How are you deploying the ejb to WebLogic ? - Kal
Any chance you're testing with a different JPA implementation than the one used in the app server? - G_H
@Kal I'm deploying using the weblogic.Deployer java class. - Brian
@Brian, if you have an EJB why is your persistence.xml in WEB-INF/classes/META-INF ? Can it not be placed in the EJB JAR itself? - Vineet Reynolds
@Brian -- My question wasn't very clear. Is the ejb deployed as part of an ear or is it a jar by itself ? If it is, then the persistence.xml should be in that ejb jar. - Kal

1 Answers

0
votes

Brian, I had the same issue here... and I solved by adding a PreDestroy method on my bean that closes EntityManagerFactory:

@PreDestroy
public void close()
{
    emf.close();
}

I hope this can help you! Please vote if it works...