NoClassDefFound: javax.persistence.criteria.CriteriaQuery [message #728084] |
Thu, 22 September 2011 14:04 |
|
Hi all,
Not sure where else to look for this one. I'm hoping for some pointers as to where I should look next.
I'm getting java.lang.NoClassDefFoundError: javax.persistence.criteria.CriteriaQuery not found from bundle [web-demo.plan-1.0.0.SNAPSHOT-com.ea.nucleus.nextgen.webdemo.db]
at $Proxy173.<clinit>(Unknown Source)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:588)
at org.springframework.orm.jpa.ExtendedEntityManagerCreator.createProxy(ExtendedEntityManagerCreator.java:264)
at org.springframework.orm.jpa.ExtendedEntityManagerCreator.createProxy(ExtendedEntityManagerCreator.java:229)
at org.springframework.orm.jpa.ExtendedEntityManagerCreator.createApplicationManagedEntityManager(ExtendedEntityManagerCreator.java:110)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.invokeProxyMethod(AbstractEntityManagerFactoryBean.java:426)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean$ManagedEntityManagerFactoryInvocationHandler.invoke(AbstractEntityManagerFactoryBean.java:485)
at $Proxy156.createEntityManager(Unknown Source)
...
Now, CriteriaQuery & co. came in JPA 2.0. This was added in Spring 3.0.3.RELEASE (see https://jira.springsource.org/browse/SPR-6636). Since Virgo 3.0 uses Spring 3.0.5.RELEASE, which is after 3.0.3.RELEASE, I'm good.
In my Virgo 3.0.x's repository/usr, I've got javax.persistence-2.0.0.jar (the OSGi bundle from groupId "org.eclipse.persistence" available from Maven Central at http://search.maven.org/remotecontent?filepath=org/eclipse/persistence/javax.persistence/2.0.0/javax.persistence-2.0.0.jar). The Virgo Admin app shows that everyone is binding properly to that bundle, including org.springframework.orm version 3.0.5.RELEASE:
The only thing suspicious that I've noticed is that there are two bundles active, 79 & 125. 79 is the one I expect from org.eclipse.virgo.region.user@file:/C:/vj/./repository/usr/javax.persistence-2.0.0.jar. 125 comes from org.eclipse.virgo.region.user@file:/C:/vj/work/org.eclipse.virgo.kernel.deployer_3.0.0.RELEASE/staging/global/bundle/javax.persistence/2.0.0.v200911271158/javax.persistence-2.0.0.jar/.
Since I'm no Virgo or Equinox expert, I didn't expect two copies of this bundle to be started. Can anyone explain whether & why I've got two JPA 2.0 bundles loaded?
Anyone have any ideas how I can get Spring ORM 3.0.5.RELEASE to see CriteriaQuery?
Thanks,
Matthew
|
|
|
|
Re: NoClassDefFound: javax.persistence.criteria.CriteriaQuery [message #728590 is a reply to message #728097] |
Fri, 23 September 2011 14:05 |
|
Glyn Normington wrote on Thu, 22 September 2011 10:23The bundle com.ea.nucleus.nextgen.webdemo.db does not appear to import the package javax.persistence.criteria, so it's not surprising that you get a NoClassDefFoundError.
How are you creating that bundle's manifest? Bundlor or bnd should have detected the usage of the class, but if you are constructing the manifest manually, you may have missed it.
I was using Apache Felix's maven-bundle-plugin (so, bnd). The bundle com.ea.nucleus.nextgen.webdemo.db doesn't use javax.persistence.criteria at all. However, that bundle does use DataNucleus, which in turn uses javax.persistence.criteria. I added Import-Bundle: javax.persistence to com.ea.nucleus.nextgen.webdemo.db's manifest, then got a NCDFE for javax.naming.NamingException. I then added javax.naming to the JDO jar manifest's Import-Package header (the JDO jar is required by DataNucleus). After that, everything worked.
There's something about transitive dependencies that I don't understand, especially with a mix of Spring 3.0.x, DataNucleus 3.0.x, JPA 2.0.x. Since it appears as though the JPA 2.0.3 jar from groupId org.eclipse.persistence is a proper OSGi bundle, I took it straight from Maven Central without modification & dropped it in repository/usr. Since we are evaluating DataNucleus as an ORM (remember, it can persist to literally any kind of datasource, relational databases being just one), we decided to create a plan for DataNucleus's relational support, using JPA as our primary API (for portability given Hibernate, OpenJPA & EclipseLink are also being evaluated) and JDO for those areas where we needed more control (fetch plans & groups). I had to modify the POMs of DataNucleus (groupId org.datanucleus) artifacts datanucleus-core & datanucleus-rdbms to use maven-bundle-plugin, then I defined a plan for DataNucleus JPA & JDO RDBMS support like so:<?xml version="1.0" encoding="UTF-8"?>
<plan name="datanucleus-ea-infra" version="3.0.2.SNAPSHOT" scoped="false"
atomic="true" xmlns="http://www.eclipse.org/virgo/schema/plan"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.eclipse.org/virgo/schema/plan
http://www.eclipse.org/virgo/schema/plan/eclipse-virgo-plan.xsd">
<artifact type="bundle" name="javax.jdo" version="3.1.0" />
<artifact type="bundle" name="javax.persistence" version="2.0.0" />
<artifact type="bundle" name="org.datanucleus" version="3.0.2" />
<artifact type="bundle" name="org.datanucleus.api.jdo" version="3.0.2" />
<artifact type="bundle" name="org.datanucleus.api.jpa" version="3.0.2" />
<artifact type="bundle" name="org.datanucleus.store.rdbms" version="3.0.2" />
<artifact type="bundle" name="org.datanucleus.jdo.query" version="3.0.0" />
<artifact type="bundle" name="org.datanucleus.jpa.query" version="3.0.0" />
</plan> If there were an authoritative blog entry by a Virgo team member or Virgo documentation chapter on configuring the major transparent persistence libraries, specifically the latest versions of Hibernate, DataNucleus, OpenJPA & EclipseLink in Virgo with Spring, including a treatment of JDBC drivers (including at least the Oracle Thin driver), I would be grateful, to say the least. To keep it simple, we have been doing compile-time enhancement, but even without load-time weaving, there is still enough proxying & dynamic loading going on to make an OSGi newbie's head spin.
|
|
|
|
Re: NoClassDefFound: javax.persistence.criteria.CriteriaQuery [message #728696 is a reply to message #728667] |
Fri, 23 September 2011 16:52 |
|
I'd actually like to do DataNucleus first. It's too bad that everyone always lists Hibernate, OpenJPA & EclipseLink, usually in that order, and omits DataNucleus. It's a good product.
I'll see what I can contribute with regard to DataNucleus. That then might be generalized to other persistence solutions.
First step is to figure out what I did and remove any extraneous manifest entries across the various bundles to get down to the bare minimum.
-matthew
|
|
|
|
Powered by
FUDForum. Page generated in 0.03137 seconds