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

          People

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

            Dates

            • Created:
              Updated:
              Resolved: