Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] JPA not working inside Equinox but fine in unit tests


Hi,

When I run unit tests for my JPA (pax Construct) project (using javax.persistence.Persistence.createEntityManagerFactory) the tests pass as expected, however when the same is deployed to Equinox (looking up and using javax.persistence.spi.PersistenceProvider) it fails repeatedly with variations of:

ValidationException: Exception Description: [class x.y.z.Abc] uses a non-entity [class x.y.z.Bcd] as target entity in the relationship attribute [field b].

(Toplink error code # 7250).

In the persistence.xml I declare:

<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
and
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<property name="eclipselink.orm.throw.exceptions " value="false" />

I'm using standard JPA annotations with no orm.xml.

I have a very simple test app that works fine (in unit tests and with equinox) with the org.eclipse.persistence.jpa.PersistenceProvider implementation, the only notable difference between my toy test app and the full scale app I'm trying to migrate is the JPA entities, but as the JPA appears to be fine outside of the OSGi environment (ie. I can get a PersistenceUnit) I'm a bit stuck as to the cause..

A big difference (though likely an effect rather than cause) is that the dynamic weaving fails in full scale app - but only when attempting to use the entities not during the actual weaving (logging is set to FINEST).  When attempting to use dynamic weaving (which works perfectly in the toy test app), the console is filled with exceptions of the form:

[EclipseLink-60]   ...  The method [_persistence_set_xxxx_vh] or [_persistence_get_xxxx_vh] is not defined in the object [x.y.z.Abc].

and

[EclipseLink-93]    ... The table [abc] is not present in this descriptor.

Although the table abc is generated in the dB.

and

[EclipseLink-41] ... A non-read-only mapping must be defined for the sequence number field.

Although the table it refers to has a correct primary key BIGINT AUTO INC (defined in generic superclass (with generic type for ID, typically Long throughout the app)

Also I've noted the following:
[EL Finer]: 2010-05-05 12:19:27.805--Could not initialize Validation Factory. Encountered following exception: java.lang.NoClassDefFoundError: javax/validation/Validation


I've played with various settings for properties: eclipselink.weaving, eclipselink.weaving.lazy and eclipselink.weaving.fetchgroups all to no avail. So without weaving (guessing it's proxy based) the unit tests work fine but I can't even acquire a EntityManagerFactory inside OSGi, as i get PersistenceUnitLoadingException -> Predeployment of PersistenceUnit [xxxx] failed.



I've tried using eclipse link versions 2.0.2, 2.1.0-M6 and 2.1.0-M7 using Equinox via a pax-construct maven build (pax runner v 1.4.0), and get virtually the same results with each eclipselink version (although the latest 2.1.0-M7 seems to completely ignore the @Column(name = "please_use_this_lower_case_name") annotations when generating the DDLs).



I'm open to the fact that it may well be my bad config/poor understanding, but as it's possible to get a PersistentUnit outside of Equinox I suspect it's a deeper problem.


Any suggestions would be most gratefully received as I am completely stumped - I'm about to try manually editing the schema but after this it seems I've only two options; debug the eclipselink code or try a wrapped hibernate implementation (i prefer the former however this project is now quite behind).



thanks,
Caspar MacRae

Back to the top