Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 328568 - Classloading problems for javax.persistence classes
Summary: Classloading problems for javax.persistence classes
Status: RESOLVED FIXED
Alias: None
Product: Gemini.JPA
Classification: RT
Component: Core (show other bugs)
Version: 1.0.0   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 1.0.0 M3   Edit
Assignee: Michael Keith CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 330530 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-10-25 03:26 EDT by Krum Tsvetkov CLA
Modified: 2010-11-18 09:50 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Krum Tsvetkov CLA 2010-10-25 03:26:15 EDT
Hi,

The bundle org.eclipse.gemini.javax.persistence has inside the javax.persistence API. This leads to troubles with classloading (see exception below) if the API is already existing in the OSGi environment. EclipseLink has its own javax.persistence bundle and having both doesn't work. At least not always (depends somehow on the startup order).

If I remove either javax.persistence (coming with EclipseLink) or org.eclipse.gemini.javax.persistence (coming with Gemini JPA), then my samples work. However, both bundles contain not only the API, but some classes from the projects. 

Will it be possible to extract the "pure" javax.persistence api out of the org.eclipse.gemini.javax.persistence bundle and declare a dependency on it?

Here is the concrete error I am facing.

java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method "$Proxy1.createEntityManagerFactory(Ljava/util/Map;)Ljavax/persistence/EntityManagerFactory;" the class loader (instance of org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) of the current class, $Proxy1, and the class loader (instance of org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) for interface org/osgi/service/jpa/EntityManagerFactoryBuilder have different Class objects for the type javax/persistence/EntityManagerFactory used in the signature
	at java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
	at java.lang.Class.getConstructor0(Class.java:2699)
	at java.lang.Class.getConstructor(Class.java:1657)
	at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:587)
	at org.eclipse.gemini.jpa.PersistenceServicesUtil.registerEMFServices(PersistenceServicesUtil.java:205)
	at org.eclipse.gemini.jpa.provider.EclipseLinkOSGiProvider.registerPersistenceUnits(EclipseLinkOSGiProvider.java:244)
	at org.eclipse.gemini.jpa.PersistenceBundleExtender.registerPersistenceUnitsInBundle(PersistenceBundleExtender.java:223)
	at org.eclipse.gemini.jpa.PersistenceBundleExtender.bundleChanged(PersistenceBundleExtender.java:278)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:919)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:227)
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:149)
	at org.eclipse.osgi.framework.internal.core.Framework.publishBundleEventPrivileged(Framework.java:1349)
	at org.eclipse.osgi.framework.internal.core.Framework.publishBundleEvent(Framework.java:1300)
	at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:356)
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:284)
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:276)
	at org.eclipse.osgi.framework.internal.core.FrameworkCommandProvider._start(FrameworkCommandProvider.java:252)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.osgi.framework.internal.core.FrameworkCommandInterpreter.execute(FrameworkCommandInterpreter.java:155)
	at org.eclipse.osgi.framework.internal.core.FrameworkConsole.docommand(FrameworkConsole.java:156)
	at org.eclipse.osgi.framework.internal.core.FrameworkConsole.runConsole(FrameworkConsole.java:141)
	at org.eclipse.osgi.framework.internal.core.FrameworkConsole.run(FrameworkConsole.java:105)
	at java.lang.Thread.run(Thread.java:619)|
Comment 1 Michael Keith CLA 2010-10-25 14:24:32 EDT
The readme should have stated that you actually need to "replace" the javax.persistence bundle that comes with EclipseLink with the one that comes with Gemini. This was a temporary measure and will go away. The latest release of EclipseLink is fixing its javax.persistence bundle to work with Gemini, so there will only be one such bundle.
Comment 2 Michael Keith CLA 2010-11-18 09:43:20 EST
No longer shipped. As of M3 drop use the javax.persistence bundle shipped with EclipseLink.
Comment 3 Michael Keith CLA 2010-11-18 09:45:44 EST
Note: The EclipseLink javax.persistence jar MUST be used (in 2.2 builds or higher) since it now includes the correct resolver, etc.
Comment 4 Michael Keith CLA 2010-11-18 09:50:22 EST
*** Bug 330530 has been marked as a duplicate of this bug. ***