| Summary: | NoClassDefFoundError CriteriaBuilder when used with ECF | ||||||
|---|---|---|---|---|---|---|---|
| Product: | z_Archived | Reporter: | Ajay <ajay.upadhyaya> | ||||
| Component: | Eclipselink | Assignee: | Nobody - feel free to take it <nobody> | ||||
| Status: | RESOLVED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P2 | CC: | ajay.upadhyaya, douglas.clarke, scastrianni, shaun.smith, tom.ware | ||||
| Version: | unspecified | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Windows XP | ||||||
| Whiteboard: | simple_fix | ||||||
| Attachments: |
|
||||||
|
Description
Ajay
Setting target and priority. See the following page for the meanings of these fields: http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines Community: Please vote for this bug if it is important to you. Votes are one of the main criteria we use to determine which bugs to fix next. I got the same problem with just a simple test program using JPA classes. My OSGI command line app would not start with the same error. I hacked the manifest of org.eclipse.persistence.jpa.osgi to add the import of javax.persistence.criteria and it worked! I tested this on Indigo RC4 with EclipseLink 2.3.0. So perhaps this is still a real bug. I've reproduced the problem and have confirmed that adding the two imports below to the o.e.p.jpa.osgi bundle's manifest allows me to run code in OSGi that uses both the Criteria API and Metamodel classes. The source of the problem is that the classloader associated with the persistence unit is constructed in o.e.p.jpa.osgi.PersistenceProvider.getClassLoader using the o.e.p.jpa.osgi bundle as one of the classloaders in the composite classloader. The recent refactoring of the OSGi code out of o.e.p.jpa into o.e.p.jpa.osgi missed these imports as they aren't referenced directly.
Missing imports:
javax.persistence.criteria;jpa="2.0",
javax.persistence.metamodel;jpa="2.0",
Sample code:
em = emf.createEntityManager();
CriteriaBuilder cb = emf.getCriteriaBuilder();
CriteriaQuery<Person> query = cb.createQuery(Person.class);
Root<Person> person = query.from(Person.class);
Predicate nameIsBob = cb.equal(person.get(Person_.name),"Bob");
query.select(person).where(nameIsBob);
Person bob = em.createQuery(query).getSingleResult();
The imports above have to be added to the BND template but when I do so I get the error below. I'm reassigning to Eric for resolution and I can verify the fix.
bnd-package:
[bnd] Warnings
[bnd] Did not find matching referal for javax.persistence.criteria.*
[bnd] Did not find matching referal for javax.persistence.metamodel.*
[bnd] Did not find matching referal for javax.persistence.spi.*
Created attachment 198768 [details]
fix to bnd file for imports.
I don't see the problem you describe..
bnd-package:
[bnd] Warnings
[bnd] Did not find matching referal for javax.persistence.criteria.*
[bnd] Did not find matching referal for javax.persistence.metamodel.*
[bnd] Did not find matching referal for javax.persistence.spi.*
The attached patch works for me...
bnd-package:
[bnd] # org.eclipse.persistence.jpa.osgi (org.eclipse.persistence.jpa.osgi_2.3.1.qualifier.jar) 13
[jar] Building jar: D:\_EL_2.3.x\plugins\org.eclipse.persistence.jpa.osgi.source_2.3.1.qualifier.jar
The patch works great for me running outside PDE. Can you also include a patch for the Manifest.MF so it reflects the change to the BND template? I cannot merge the generated manifest directly because there are other changes needed, and those changes will need to be mirrored in the other projects. Tom is planning on globally updating the manifests on 2.3 soon. Trunk will also be changing in a few days. I've been asked to go ahead and switch 2.4.0 to use Tycho, so I don't plan on merging this fix to Trunk - only to remove BND completely a day or so later. In the meantime, the import section of the checked-in manifest can be replaced with the one below to fix the issue within PDE: Import-Package: javax.persistence;jpa="2.0",javax.persistence.criteria ;jpa="2.0",javax.persistence.metamodel;jpa="2.0",javax.persistence.sp i;jpa="2.0",org.eclipse.persistence.exceptions,org.eclipse.persistenc e.internal.jpa.deployment,org.eclipse.persistence.internal.localizati on,org.eclipse.persistence.jpa,org.eclipse.persistence.logging,org.os gi.framework,org.osgi.service.jpa,org.osgi.service.packageadmin Tom has updated the manifests on the 2.3 branch.. I'll now merge the changes. merged to both trunk and 2.3. figured better to be in sync. despite pending changes on trunk. The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |