JPOX MetaDataForPersistenceCapableClassNotReachableException
Here's a solution I found for a strange error in JPOX. While working with JPOX, Clover, JUnit and Maven, I kept getting the following:
Testcase: testIdeaPersistenceManager(org.eremite.triune.hypernym.IdeaTest): Caused an ERROR The class "org.eremite.triune.hypernym.Idea" is required to be Persistence-Capable yet no Meta-Data can be found for this class. Please check that the Meta-Data is defined in a valid file location for JDO. org.jpox.exceptions.MetaDataForPersistenceCapableClassNotReachableException: The class "org.eremite.triune.hypernym.Idea" is required to be Persistence-Capable yet no Meta-Data can be found for this class. Please check that the Meta-Data is defined in a valid file location for JDO. at org.jpox.AbstractPersistenceManager. assertPersistenceCapable(AbstractPersistenceManager.java:414) at org.jpox.AbstractPersistenceManager. internalMakePersistent(AbstractPersistenceManager.java:897) at org.jpox.AbstractPersistenceManager. makePersistent(AbstractPersistenceManager.java:995) at org.eremite.triune.persistence.IdeaPersistenceManager. storeIdea(IdeaPersistenceManager.java:34) at org.eremite.triune.hypernym.IdeaTest. testIdeaPersistenceManager(IdeaTest.java:85) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl. invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl. invoke(DelegatingMethodAccessorImpl.java:25)
However, I was not getting the same error when just using JPOX, Maven and JUnit. The tests were only breaking with Clover. The trick is that the package.jdo files were not being copied to the target/clover/classes/ directory. I was copying them in a <postGoal> element for java:compile in my maven.xml, but I was not doing the same in a <preGoal> element for clover:test. So, adding the following block to my maven.xml completely resolved the problem:
<!-- Perform enhance directly after compilation -->
<preGoal name="clover:test">
<copy todir="${basedir}/target/clover/classes/">
<fileset dir="${basedir}/src/java">
<include name="**/*.jdo"/>
</fileset>
</copy>
<attainGoal name="jpox:enhance"/>
</preGoal>
Hope this helps someone.
