Issue Details (XML | Word | Printable)

Key: GLASSFISH-18508
Type: Bug Bug
Status: Closed Closed
Resolution: Invalid
Priority: Major Major
Assignee: Sanjeeb Sahoo
Reporter: aaronjwhiteside
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.

ClassNotFoundException: org.eclipse.persistence.jpa.PersistenceProvider

Created: 14/Mar/12 08:02 PM   Updated: 16/Mar/12 02:00 PM   Resolved: 15/Mar/12 05:45 AM
Component/s: classloader, OSGi
Affects Version/s: 3.1.2
Fix Version/s: None

Time Tracking:
Not Specified

Participants: aaronjwhiteside and Sanjeeb Sahoo

 Description  « Hide

Using the workaround provided in:

Enabling the HybridPersistenceProviderResolver in and using the following code to create the EntityManagerFactory:

ClassLoader old = Thread.currentThread().getContextClassLoader();
        try {
            Thread.currentThread().setContextClassLoader( OSGiEntityManagerFactoryFactory.class.getClassLoader() );
            EntityManagerFactory emf = Persistence.createEntityManagerFactory( persistenceUnitName );
            return emf;
        } finally {
            Thread.currentThread().setContextClassLoader( old );

Produces the following exception, after 2 EntityMangerFactory's have been created. The third and fourth receive this error. Not sure why this succeeds in the first two bundles but fail in the others.

[#|2012-03-14T15:55:26.737-0400|WARNING|glassfish3.1.2|org.glassfish.osgijpa.extension|_ThreadID=101;_ThreadName=Thread-2;|Exception trying to instantiate cached provider by name org.eclipse.persistence.jpa.PersistenceProvider
java.lang.ClassNotFoundException: org.eclipse.persistence.jpa.PersistenceProvider not found by [296]
	at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(
	at org.apache.felix.framework.BundleWiringImpl.access$400(
	at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(
	at java.lang.ClassLoader.loadClass(
	at org.glassfish.osgijpa.extension.HybridPersistenceProviderResolver.convert(
	at org.glassfish.osgijpa.extension.HybridPersistenceProviderResolver.readCache(
	at org.glassfish.osgijpa.extension.HybridPersistenceProviderResolver.getPersistenceProviders(
	at org.glassfish.osgijpa.extension.HybridPersistenceProviderResolver.getPersistenceProviders(
	at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
	at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
	at java.lang.reflect.Method.invoke(
	at org.eclipse.gemini.blueprint.util.internal.PrivilegedUtils.executeWithCustomTCCL(
	at org.eclipse.gemini.blueprint.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$

aaronjwhiteside added a comment - 14/Mar/12 09:25 PM

You can close this issue, turns out it was caused by something left in my osgi-cache folder, after deleting that and restarting the domain this issue disappeared.

Sanjeeb Sahoo added a comment - 15/Mar/12 05:45 AM

Not a bug as user had made some configuration mistakes.

aaronjwhiteside added a comment - 15/Mar/12 11:06 PM

Actually can you please re-open this bug. Turns out that clearing the osgi-cache has not effect, the issue is sporadic.

Some times it happens some times it does not, I just happened to work after I cleared the osgi-cache.

Sanjeeb Sahoo added a comment - 16/Mar/12 03:40 AM

Don't you have permission to open/close JIRA issues? Pl. attach a test case and reopen the issue.

Sanjeeb Sahoo added a comment - 16/Mar/12 05:19 AM

BTW, is the CNFE exception preventing your app to work or are you just worried by it being logged? HybridPersistenceProviderResolver code should fall back to discovering providers when it is unable to find providers in the cache.

aaronjwhiteside added a comment - 16/Mar/12 02:00 PM

I don't have permission to open/close JIRA issues.

Coming up with a test case might be difficult as it is sporadic. THE CNFE exception is preventing my application from loading a EMF.

I think this issue might be related to another I reported (read comments in that issue): GLASSFISH-18514

As the bundle org.glassfish.fighterfish.osgi-jpa has a run level of 2, and my jpa'd bundle has a run level of 1.