DataNucleus JIRA is now in read-only mode. Raise any new issues in GitHub against the plugin that it applies to. DataNucleus JIRA will remain for the foreseeable future but will eventually be discontinued
Issue Details (XML | Word | Printable)

Key: NUCJPA-221
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Oliver Gierke
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.
DataNucleus API JPA

Documentation on how to set up entity enhancement seems to be broken

Created: 17/Feb/13 03:48 PM   Updated: 20/Feb/13 12:05 PM   Resolved: 18/Feb/13 12:13 PM
Component/s: None
Affects Version/s: 3.1.4
Fix Version/s: 3.1.4

 Description  « Hide
I've tried to include DataNucleus into the Spring Data JPA integration test suite together and tried quite a few approaches to get the enhancement working for the second time, and failed again:

- using the Maven plugin but there doesn't seem to be a way to enhance test classes (I googled but there neither seem to exist an enhance-test-classes goal nor an ability to set the source folder to pick up classes from). Is there any documentation on how to set up enhanceing for classes from src/test/java?
- runtime enhancement using a load time weaver. I followed There's no enhancer in current datanucleus-core jars (I used 3.1.4). So I tried datanucleus-enhancer jar (which I found references to on other google results) which is even more related to JDO, so I guess that was a wrong path as well. I then went with addClassTransformer and a Spring load time weaver but that left my entites unenhanced.

All in all I couldn't find any place in the reference docs that contained a working example of how to set up JPA enhancement that works. The fact, that there exists such documentation made me scratching my head even more facing all the JDO related exceptions as I wasn't expecting to see them as I wanted to setup JPA.

Finally I found a repo containing a complete example That uses the maven plugin (which I'd like to avoid as I need run test cases against other JPA providers as well and wat to avoid the enhancing of DataNucleus to interfere with these executions) but also only enhances src/main/java classes.

Is there some up-to-date documentation for the JPA setup I have missed?

Andy Jefferson added a comment - 17/Feb/13 04:42 PM - edited
If you're using 3.1 then you use the link for 3.1, as per
the "accessplatform" link you had is a hyperlink to latest (current) codebase (i.e 3.2).

For JPA you enhance a "persistence-unit", so as long as the META-INF/persistence.xml is available in the CLASSPATH (for that unit) with those (test) classes then they will be enhanced. If they aren't then kindly provide a (very simple) example with a test class and pom.xml for comment so we can see what is missing. The enhancer (being a Java process) obviously cares little where the classes are exactly as long as they're in the CLASSPATH

Oliver Gierke added a comment - 17/Feb/13 05:54 PM
Thanks for taking time for this, Andy. I see, I hadn't expected the plain "accessplatform" link to point to 3.2 as it's in milestone releases only (not GA yet), but that clears things up now.

I've set up a sample project at trying to bootstrap Datanucleus using runtime enhancement both through plain JPA API as well as through Spring's infrastructure. Both fail with the same error message ("Caused by: org.datanucleus.exceptions.NucleusUserException: Found Meta-Data for class de.olivergierke.samples.datanucleus.Person but this class is not enhanced!! Please enhance the class before running DataNucleus.").

Oliver Gierke added a comment - 17/Feb/13 06:08 PM
I think I got to the core of the problem. With Spring 3.1.2 I still had to include CGLib which transitively pulls ASM 3.x into the classpath. This apparently interferes with the Enhancer classes you ship as they apparently depend on ASM 4.x. So at runtime one now sees an IncompatibleClassChangeError that cases the enhancement to break but not the runtime to stop.

Might be worth to keep this around for people also stumbling into this and maybe add a hint to the reference docs?

Thanks for your assistance and sorry for the noise!

Andy Jefferson added a comment - 17/Feb/13 06:35 PM
Thanks Oliver, glad you found the problem, and I'll update the 3.1 docs to include that.
In v3.2 it has ASM 4.x repackaged internally so that specific issue shouldn't happen. Noise is fine if it means things get made better, or easier for people ;-)

Andy Jefferson added a comment - 18/Feb/13 12:13 PM
Online docs for 3.1 now mention about ASM version conflicts

Andy Jefferson made changes - 18/Feb/13 12:13 PM
Field Original Value New Value
Status Open [ 1 ] Resolved [ 5 ]
Fix Version/s 3.1.4 [ 11810 ]
Resolution Fixed [ 1 ]
Andy Jefferson made changes - 20/Feb/13 12:05 PM
Status Resolved [ 5 ] Closed [ 6 ]