Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » NoClassDefFound: javax.persistence.criteria.CriteriaQuery
NoClassDefFound: javax.persistence.criteria.CriteriaQuery [message #728084] Thu, 22 September 2011 14:04 Go to next message
Matthew T. Adams is currently offline Matthew T. AdamsFriend
Messages: 58
Registered: July 2009
Location: Austin, TX
Member

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:
http://img268.imageshack.us/img268/695/virgo1.jpg
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 #728097 is a reply to message #728084] Thu, 22 September 2011 14:23 Go to previous messageGo to next message
Glyn Normington is currently offline Glyn NormingtonFriend
Messages: 1222
Registered: July 2009
Senior Member
The 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.
Re: NoClassDefFound: javax.persistence.criteria.CriteriaQuery [message #728590 is a reply to message #728097] Fri, 23 September 2011 14:05 Go to previous messageGo to next message
Matthew T. Adams is currently offline Matthew T. AdamsFriend
Messages: 58
Registered: July 2009
Location: Austin, TX
Member

Glyn Normington wrote on Thu, 22 September 2011 10:23
The 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 #728667 is a reply to message #728590] Fri, 23 September 2011 16:00 Go to previous messageGo to next message
Dmitry Sklyut is currently offline Dmitry SklyutFriend
Messages: 279
Registered: January 2010
Senior Member
Oh boy Smile Ok. We should start a wiki page on this. What do you want first? Hibernate? OpenJPA? EclipseLink? With/without spring? With or without using gemini jpa/data-access? Scoped or un-scoped?

There are little gotchas with each solution. Hibernate is especially hard because of split packages between modules. EclipseLink uses Require-Bundle. JDBC Drivers are a pain at times as they may have a ton of optional dependencies. OpenJPA - never used it Smile
With Spring - there other classloading issues as it sets up thread context classloader internally for app context usage.

It would help if you could provide an example use case(s). We would be able to build it out and figure out all of the edge cases and write that up. Without a good use case it is hard to anticipate those edge cases.
Simple Spring + Hibernate works like a charm in a scoped plan for example.

Thank you in advance and also for asking questions and pushing us Smile
Re: NoClassDefFound: javax.persistence.criteria.CriteriaQuery [message #728696 is a reply to message #728667] Fri, 23 September 2011 16:52 Go to previous messageGo to next message
Matthew T. Adams is currently offline Matthew T. AdamsFriend
Messages: 58
Registered: July 2009
Location: Austin, TX
Member

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
Re: NoClassDefFound: javax.persistence.criteria.CriteriaQuery [message #729430 is a reply to message #728696] Mon, 26 September 2011 07:43 Go to previous message
Glyn Normington is currently offline Glyn NormingtonFriend
Messages: 1222
Registered: July 2009
Senior Member
Hi Matthew

If you pare down your app to be a DataNucleus sample, feel free to put it on github and we can reference it from Virgo.

BTW years of experience with OSGi doesn't make you immune to head spinning when it comes to ORM. I guess it's that ORM is complex, especially when you have to understand some parts of the implementation in order to get it going with OSGi. I'm so pleased Dmitry is a Virgo committer as it's great to have an ORM expert in the team!

Regards,
Glyn
Previous Topic:Pointers on debugging bundle startup times
Next Topic:JAX bundles included with Virgo
Goto Forum:
  


Current Time: Wed Apr 24 21:26:28 GMT 2024

Powered by FUDForum. Page generated in 0.03490 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top