glassfish
  1. glassfish
  2. GLASSFISH-18508

ClassNotFoundException: org.eclipse.persistence.jpa.PersistenceProvider

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Invalid
    • Affects Version/s: 3.1.2
    • Fix Version/s: None
    • Component/s: classloader, OSGi
    • Labels:
      None

      Description

      Using the workaround provided in:

      http://glassfish.java.net/public/GF-OSGi-Features.pdf

      Enabling the HybridPersistenceProviderResolver in osgi.properties 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 );
                  emf.createEntityManager().close();
                  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 com.mm.mtrust.common.db [296]
      	at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1460)
      	at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:72)
      	at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1843)
      	at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
      	at org.glassfish.osgijpa.extension.HybridPersistenceProviderResolver.convert(HybridPersistenceProviderResolver.java:155)
      	at org.glassfish.osgijpa.extension.HybridPersistenceProviderResolver.readCache(HybridPersistenceProviderResolver.java:123)
      	at org.glassfish.osgijpa.extension.HybridPersistenceProviderResolver.getPersistenceProviders(HybridPersistenceProviderResolver.java:104)
      	at org.glassfish.osgijpa.extension.HybridPersistenceProviderResolver.getPersistenceProviders(HybridPersistenceProviderResolver.java:98)
      	at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
      	at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
      	at com.mm.common.db.osgi.OSGiEntityManagerFactoryFactory.create(OSGiEntityManagerFactoryFactory.java:28)
      	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:601)
      	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:145)
      	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:570)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:982)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:878)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:484)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
      	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
      	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
      	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
      	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
      	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
      	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
      	at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:60)
      	at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:325)
      	at org.eclipse.gemini.blueprint.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
      	at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:290)
      	at org.eclipse.gemini.blueprint.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:137)
      	at java.lang.Thread.run(Thread.java:722)
      

        Activity

        Hide
        aaronjwhiteside added a comment -

        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.

        Show
        aaronjwhiteside added a comment - 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.
        Hide
        Sanjeeb Sahoo added a comment -

        Not a bug as user had made some configuration mistakes.

        Show
        Sanjeeb Sahoo added a comment - Not a bug as user had made some configuration mistakes.
        Hide
        aaronjwhiteside added a comment -

        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.

        Show
        aaronjwhiteside added a comment - 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.
        Hide
        Sanjeeb Sahoo added a comment -

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

        Show
        Sanjeeb Sahoo added a comment - Don't you have permission to open/close JIRA issues? Pl. attach a test case and reopen the issue.
        Hide
        Sanjeeb Sahoo added a comment -

        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.

        Show
        Sanjeeb Sahoo added a comment - 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.
        Hide
        aaronjwhiteside added a comment -

        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.

        Show
        aaronjwhiteside added a comment - 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.

          People

          • Assignee:
            Sanjeeb Sahoo
            Reporter:
            aaronjwhiteside
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: