This discussion is archived
1 Reply Latest reply: May 24, 2012 6:55 AM by JamesSutherland RSS

verify that this class has been marked with the @Entity annotation

875198 Newbie
Currently Being Moderated
Hi,


We have a App level shared lib which does all the JPA related query for an app. And each app can utilize the share lib to get the JPA related query to be done.
For scoping the JPA between App . We have created EMF for each app.

When one app run and does any JPA related action it works fine , but when we try to run second app we are seeing the following error when trying to do JPA specific action .


the @Entity annotation.
[2012-05-23T04:08:16.839-07:00] [WC_Spaces] [ERROR] [] [oracle.webcenter.spaces] [tid: [ACTIVE].ExecuteThread: '3' for queue: 'weblogic.kernel.Default (self-tuning)'] [ecid: 5825b814-2931-4ad5-8dc3-3e18f66992b7-00000004,0] [APP: webcenterCustom] [[
java.lang.IllegalArgumentException: Unknown entity bean class: class oracle.webcenter.spaces.internal.repository.WcSpaceHeader, please verify that this class has been marked with the @Entity annotation.
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.find(EntityManagerImpl.java:648)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.find(EntityManagerImpl.java:532)
at oracle.webcenter.spaces.internal.repository.SpaceRepositoryUtils.refreshSpaceRows(SpaceRepositoryUtils.java:1791)


Where WcSpaceHeader is an Entity.

For creating emf per App this is the code


private static EntityManagerFactory getEntityManagerFactory()
{
String appName=Utility.getApplicationName();
EntityManagerFactory emf=sEntityMgrFactory.get(appName);

if(emf==null)
{
emf=Persistence.createEntityManagerFactory("SpacesReposPUnit");
sEntityMgrFactory.put(appName,emf);
SpacesConstants.LOGGER.info("Caching" +
"EMF for " +appName);  
}

return emf;
}



My persistence.xml

<?xml version="1.0" encoding="US-ASCII" ?>
<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="SpacesReposPUnit" transaction-type="RESOURCE_LOCAL">
<provider>
org.eclipse.persistence.jpa.PersistenceProvider
</provider>
<class>oracle.webcenter.spaces.internal.repository.WcSpaceHeader</class>
<class>oracle.webcenter.spaces.internal.repository.WcSpaceUsrDetail</class>
<class>oracle.webcenter.framework.service.jpa.WcCommonXlationEntity</class>
<class>oracle.webcenter.spaces.internal.repository.WCNavigationActivity</class>
<properties>
<property name="eclipselink.session.customizer"
value="oracle.webcenter.spaces.internal.repository.SpacesEclipselinkSessionCustomizer"/>
</properties>
</persistence-unit>
</persistence>



One more problem i am seeing in this is that . When i create an EM from EMF (which is diff for diff app) and doing some query i am getting a class cast Exception.


(self-tuning)'] [ecid: 5825b814-2931-4ad5-8dc3-3e18f66992b7-00000004,0] [APP: webcenterCustom] [[
java.lang.IllegalArgumentException: Unknown entity bean class: class oracle.webcenter.spaces.internal.repository.WcSpaceHeader, please verify that this class has been marked with the @Entity annotation.
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.find(EntityManagerImpl.java:648)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.find(EntityManagerImpl.java:532)
  • 1. Re: verify that this class has been marked with the @Entity annotation
    JamesSutherland Pro
    Currently Being Moderated
    This is a class loader issue, somehow you have deployed the same classes in two places, so have two different versions of the classes.

    How, exactly have you deployed things, where are your domain classes?

    The issues is most likely that,
    Persistence.createEntityManagerFactory("SpacesReposPUnit");
    will always return the same factory once it has been deployed.

    If you pass a properties map to createEntityManagerFactory and set the property "eclipselink.session-name" to a unique value, then you should get a new factory.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points