You are using EclipseLink with weaving, and it doesn't work. You should try without weaving.
Probably by editing your persistence.xml
(s)
<persistence-unit name="XXX" transaction-type="XXX">
<jta-data-source>XXX</jta-data-source>
<jar-file>Or List of Classes or something else</jar-file>
<properties>
[other properties]
<property name="eclipselink.weaving" value="false"/>
</properties>
</persistence-unit>
Update:
There are several alternative ways a JPA implementation could handle entities, this is a none exhausting list:
- Extension (this is way the JPA spec requires a none private default
constuctor for entities)
- Wrapping
- Byte code manipulation of the class (to make it conform to how EclipseLink "wants" it to be)
- ThreadLocal proxy thingie
- Basic reflection using the properties
- Basic reflection using the getters setters (if there are any)
EclipseLink calls byte code injection "Weaving" ( What is Java bytecode injection? )
Dynamic weaving is doing the weaving at "runtime" - basically when the class is loaded by a class loader.
Static weaving is doing the weaving before deployment, but after compilation.
For EclipseLink weaving is the fastest method performance wise, it is also the prefered method for other reasons. Unfortuneatly it is often a bit tricky to get weaving to work. It is fully possible none of that matters for your project, it doesn't for a lot of typical projects.
If there are clients that access beans via an remote interface, and there are entities passed as arguments or returns value through that connection dynamic weaving won't work.
In most production scenarios, especially if the app/product isn't very small static weaving is prefered over dynamic weaving anyways ...
To read more about static vs dynamic weaving and how to configure it I haven't really found any excellent sources, but this one is at least semi official:
Using_EclipseLink_JPA_Weaving
What was happening to you was that the entity was weaved at one end and not weaved at the other -> can absolutely not work.
The good news is that you probably don't have to care about any of this weaving thing at all, or you might.
When you disabled weaving, EclipseLink fell back to another method for handling the JPA entities.
There are some functions EclipseLink only supports if weaving is enabled (none JPA required though).
From: What_You_May_Need_to_Know_About_Weaving_JPA_Entities
Comes a list of things that EclipseLink explicitly uses weaving for:
- lazy loading (indirection)
- change tracking
- fetch groups
- internal optimizations
(For some of them there are fallbacks to other methods if weaving is disabled, I'd guess all but "internal optimizations")