Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Gemini » Gemini JPA runtime problem( I get an odd ClassNotFoundException when including any JPA classes)
Gemini JPA runtime problem [message #1219617] Wed, 04 December 2013 23:58 Go to next message
Damon Jacobsen is currently offline Damon JacobsenFriend
Messages: 1
Registered: December 2013
Junior Member
I am attempting to get JPA and OSGi working together for the first. I have managed to navigate many pitfalls until this one.

I can successfully connect to the DB and run a bogus query

package activator;


import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.util.tracker.ServiceTracker;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;

public class JPABundleActivator implements BundleActivator {
// private BundleContext bundleContext;
// private ServiceTracker serviceTracker;

void log(String msg) {
System.out.println("===== " + msg);
}

@Override
public void start(final BundleContext bundleContext) throws Exception {
log("Starting bundle");
final ServiceTracker serviceTracker = new ServiceTracker(bundleContext, EntityManagerFactory.class.getName(), null);
serviceTracker.open();
new Thread(new Runnable() {
@Override
public void run() {
try {
serviceTracker.waitForService(0);
EntityManagerFactory entityManagerFactory = (EntityManagerFactory) serviceTracker.getService();
EntityManager entityManager = entityManagerFactory.createEntityManager();
System.out.println(entityManager.createNativeQuery("SELECT 'hello'").getSingleResult());
// entityManager.find(OrdHeader.class,1);

} catch (InterruptedException e) {
e.printStackTrace();
}

}
}).start();
// PcsDevice pcsDevice =entityManagerFactory.createEntityManager().find(PcsDevice.class,1);
// System.out.println(pcsDevice.getXref1Txt());

}

@Override
public void stop(BundleContext bundleContext) throws Exception {
log("Stopping bundle");
}
}

Results:
Created Framework: org.knopflerfish.framework, version=7.0.1.
Framework launched
> ===== Starting bundle
===== Stopping bundle
[EL Info]: transaction: 2013-12-04 15:53:22.135--ServerSession(284165615)--property eclipselink.jdbc.user is deprecated, property javax.persistence.jdbc.user should be used instead.
.......
hello

The minute I add an entity class to the persistence.xml however, I get :

Created Framework: org.knopflerfish.framework, version=7.0.1.
Framework launched
> ===== Starting bundle
===== Stopping bundle
[EL Info]: transaction: 2013-12-04 15:56:40.487--ServerSession(824784700)--property eclipselink.jdbc.user is deprecated, property javax.persistence.jdbc.user should be used instead.
.....
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.gemini.jpa.proxy.EMFServiceProxyHandler.invoke(EMFServiceProxyHandler.java:75)
at com.sun.proxy.$Proxy0.createEntityManager(Unknown Source)
at activator.JPABundleActivator$1.run(JPABundleActivator.java:31)
at java.lang.Thread.run(Thread.java:744)
Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-28019] (Eclipse Persistence Services - 2.4.2.v20130514-5956486): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Deployment of PersistenceUnit [persistenceUnit] failed. Close all factories for this PersistenceUnit.
Internal Exception: java.lang.NoClassDefFoundError: org/eclipse/persistence/internal/jpa/rs/metadata/model/Link
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.createDeployFailedPersistenceException(EntityManagerSetupImpl.java:628)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:608)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:186)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:278)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:304)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:282)
... 8 more
Caused by: Exception [EclipseLink-28019] (Eclipse Persistence Services - 2.4.2.v20130514-5956486): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Deployment of PersistenceUnit [persistenceUnit] failed. Close all factories for this PersistenceUnit.
Internal Exception: java.lang.NoClassDefFoundError: org/eclipse/persistence/internal/jpa/rs/metadata/model/Link
at org.eclipse.persistence.exceptions.EntityManagerSetupException.deployFailed(EntityManagerSetupException.java:229)
... 14 more
Caused by: java.lang.NoClassDefFoundError: org/eclipse/persistence/internal/jpa/rs/metadata/model/Link
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2531)
at java.lang.Class.getDeclaredMethods(Class.java:1855)
at org.eclipse.persistence.internal.security.PrivilegedAccessHelper.getDeclaredMethods(PrivilegedAccessHelper.java:324)
at org.eclipse.persistence.internal.jpa.metadata.listeners.EntityListenerMetadata.getDeclaredMethods(EntityListenerMetadata.java:255)
at org.eclipse.persistence.internal.jpa.metadata.listeners.EntityClassListenerMetadata.process(EntityClassListenerMetadata.java:89)
at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.processListeners(EntityAccessor.java:1071)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.addEntityListeners(MetadataProcessor.java:134)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:481)
... 12 more
Caused by: java.lang.ClassNotFoundException: org.eclipse.persistence.internal.jpa.rs.metadata.model.Link
at org.knopflerfish.framework.BundleClassLoader.findClass(BundleClassLoader.java:218)
at org.knopflerfish.framework.BundleClassLoader.loadClass(BundleClassLoader.java:347)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 21 more
[EL Severe]: ejb: 2013-12-04 15:56:40.732--ServerSession(1805360983)--java.lang.NoClassDefFoundError: org/eclipse/persistence/internal/jpa/rs/metadata/model/Link
Exception in thread "Thread-1" java.lang.NullPointerException
at activator.JPABundleActivator$1.run(JPABundleActivator.java:32)
at java.lang.Thread.run(Thread.java:744)
Re: Gemini JPA runtime problem [message #1219625 is a reply to message #1219617] Thu, 05 December 2013 01:16 Go to previous message
Michael Keith is currently offline Michael KeithFriend
Messages: 243
Registered: July 2009
Senior Member
Hi Damon,

This is kind of a strange one since that class should be in the org.eclipse.persistence.core bundle. I don't see how you would be able to run the first test if you didn't have the core bundle installed. That class was introduced in 2.4.2, is it possible that you have a 2.4.1 core bundle mixed in with 2.4.2 jpa bundle?

-Mike
Previous Topic:How can I outsource persistence.xml plugin in a fragment?
Next Topic:p2 repository for h2 Driver?
Goto Forum:
  


Current Time: Thu Dec 12 06:48:56 GMT 2024

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

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

Back to the top