Rohit,

If you don't want to create persistence.xml, you can specify persistent classes 
by calling AbstractTestCase.setUp(Object... props).

Regards,
Milosz
 
> 
> After some investigation I have resolved this issue.
> 
> These are my findings:
> 
> Yes It is necessary for all persistable entities to be defined in the
> persistence.xml files when running standalone.
> 
> It is important for the testcase to load the EMFs from the correct
> persistence.xml. The error below was due to loading an incorrect
> persistence.xml  in the test case.
> 
> The relevant code is in
> /openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/common/utils/AbstractTestCase.java
> 
> 
>     protected String computePersistenceXmlResource(String s) {
>         String resourceName = getClass().getPackage().getName()
>             .replaceAll("\\.", "/");
>         resourceName += "/common/apps/META-INF/persistence.xml";
>         URL resource =
> getClass().getClassLoader().getResource(resourceName);
>         
>         if (resource != null){
>             System.out.println("*** Loading persistence.xml "+
> resourceName);
>             return resourceName;
>         } else {
>             System.err.println("*** Could NOT find "+ resourceName+ " Now
> returning default persistence resource ");
>             return defaultPersistenceXmlResource();
>         }
>     }
> 
> I would really like for these log statements to get added to this testcase
> for future guidance.
> 
> --Thanks,
> Rohit Kelapure
> 
> 
> 
> 
> 
> 
> 
> 
> Rohit Kelapure wrote:
> > 
> > I am trying to execute org.apache.openjpa.persistence.datacache.CacheTest
> > with a custom cache provider. 
> > 
> > In spite of having ALL entity classes on the classpath when executing the
> > test, openJPA complains that 
> > the entity was not found in the list of persistent types.
> > 
> > <openjpa-2.0.0-SNAPSHOT-r422266:824213 fatal user error>
> > org.apache.openjpa.persistence.ArgumentException: No metadata was found
> > for type "class
> > org.apache.openjpa.persistence.datacache.common.apps.CacheObjectA". The
> > class does not appear in the list of persistent types:
> > [org.apache.openjpa.persistence.common.apps.Student, ...........].
> > 
> > When I decompiled CacheObjectA in
> > C:\open-jpa\openjpa-trunk\openjpa-persistence-jdbc\target\test-classes\org\apache\openjpa\persistence\datacache\common\apps,
> > I saw that CacheObjectA implements  PersistenceCapable which means that
> > the enhancer did its job.
> > 
> > The surefire plugin test classpath does contain the
> > C:\open-jpa\openjpa-trunk\openjpa-persistence-jdbc\target\test-classes dir
> > on its classpath
> > 
> > What does one need to do to get OpenJPA to recognize a persistence capable
> > class ?
> > Is it necessary for all persistable entities to be defined in the orm xml
> > files in addition to having the @Entity annotation ?
> > 
> > --Thanks,
> > Rohit Kelapure
> > 
> 
> -- 
> View this message in context: 
> http://n2.nabble.com/Running-CacheTest-class-does-not-appear-in-the-list-of-persistent-types-tp3810164p3811051.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
> 

Reply via email to