Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-1490

ClassNotFoundExceptions in an OSGi environment

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 2.0.0-beta
    • None
    • diagnostics, osgi
    • None
    • OSGi

    Description

      OpenJPA is available packaged as an OSGi bundle, and specifies several optional package imports, for example the serp packages.

      When calling createContainerEntityManagerFactory() these imports are no longer optional, and NoClassDefFoundErrors are generated. These exceptions should be handled more gracefully, rather than simply being thrown back to the user.

      Examples follow:

      java.lang.NoClassDefFoundError: javax.transaction.Synchronization
      at java.lang.ClassLoader.defineClassImpl(Native Method)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:265)
      at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.defineClass(DefaultClassLoader.java:183)
      at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClass(ClasspathManager.java:576)
      at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findClassImpl(ClasspathManager.java:546)
      at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClassImpl(ClasspathManager.java:477)
      at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass_LockClassLoader(ClasspathManager.java:465)
      at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:445)
      at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:211)
      at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:376)
      at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:452)
      at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:405)
      at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:393)
      at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:105)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:609)
      at java.lang.ClassLoader.defineClassImpl(Native Method)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:265)
      at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.defineClass(DefaultClassLoader.java:183)
      at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClass(ClasspathManager.java:576)
      at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findClassImpl(ClasspathManager.java:546)
      at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClassImpl(ClasspathManager.java:477)
      at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass_LockClassLoader(ClasspathManager.java:465)
      at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:445)
      at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:211)
      at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:376)
      at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:452)
      at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:405)
      at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:393)
      at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:105)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:609)
      at java.lang.J9VMInternals.verifyImpl(Native Method)
      at java.lang.J9VMInternals.verify(J9VMInternals.java:72)
      at java.lang.J9VMInternals.initialize(J9VMInternals.java:134)
      at org.apache.openjpa.conf.OpenJPAConfigurationImpl.<init>(OpenJPAConfigurationImpl.java:221)
      at org.apache.openjpa.conf.OpenJPAConfigurationImpl.<init>(OpenJPAConfigurationImpl.java:195)
      at org.apache.openjpa.conf.OpenJPAConfigurationImpl.<init>(OpenJPAConfigurationImpl.java:186)
      at org.apache.openjpa.persistence.PersistenceProviderImpl.newConfigurationImpl(PersistenceProviderImpl.java:230)
      at org.apache.openjpa.persistence.PersistenceProviderImpl.createContainerEntityManagerFactory(PersistenceProviderImpl.java:166)
      at org.apache.openjpa.persistence.PersistenceProviderImpl.createContainerEntityManagerFactory(PersistenceProviderImpl.java:62)
      at org.apache.aries.jpa.container.impl.EntityManagerFactoryManager.createEntityManagerFactories(EntityManagerFactoryManager.java:227)
      at org.apache.aries.jpa.container.impl.EntityManagerFactoryManager.bundleStateChange(EntityManagerFactoryManager.java:121)
      at org.apache.aries.jpa.container.impl.PersistenceBundleManager.modifiedBundle(PersistenceBundleManager.java:197)
      at org.apache.aries.util.tracker.MultiBundleTracker$InternalBundleTracker.modifiedBundle(MultiBundleTracker.java:108)
      at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:453)
      at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:237)
      at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:413)
      at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:916)
      at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:220)
      at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:149)
      at org.eclipse.osgi.framework.internal.core.Framework.publishBundleEventPrivileged(Framework.java:1350)
      at org.eclipse.osgi.framework.internal.core.Framework.publishBundleEvent(Framework.java:1301)
      at org.eclipse.osgi.framework.internal.core.BundleHost.stopWorker(BundleHost.java:490)
      at org.eclipse.osgi.framework.internal.core.AbstractBundle.suspend(AbstractBundle.java:546)
      at org.eclipse.osgi.framework.internal.core.Framework.suspendBundle(Framework.java:1098)
      at org.eclipse.osgi.framework.internal.core.PackageAdminImpl.suspendBundle(PackageAdminImpl.java:314)
      at org.eclipse.osgi.framework.internal.core.PackageAdminImpl.processDelta(PackageAdminImpl.java:460)
      at org.eclipse.osgi.framework.internal.core.PackageAdminImpl.doResolveBundles(PackageAdminImpl.java:241)
      at org.eclipse.osgi.framework.internal.core.PackageAdminImpl$1.run(PackageAdminImpl.java:176)
      at java.lang.Thread.run(Thread.java:735)
      Caused by: java.lang.ClassNotFoundException: javax.transaction.Synchronization
      at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:489)
      at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:405)
      at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:393)
      at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:105)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:609)
      ... 59 more

      java.lang.NoClassDefFoundError: serp.util.Strings
      at org.apache.openjpa.lib.conf.Configurations.newInstance(Configurations.java:200)
      at org.apache.openjpa.lib.conf.ObjectValue.newInstance(ObjectValue.java:124)
      at org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:103)
      at org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectValue.java:83)
      at org.apache.openjpa.lib.conf.ConfigurationImpl.getLogFactory(ConfigurationImpl.java:209)
      at org.apache.openjpa.lib.conf.ConfigurationImpl.getLog(ConfigurationImpl.java:226)
      at org.apache.openjpa.conf.OpenJPAConfigurationImpl.getConfigurationLog(OpenJPAConfigurationImpl.java:1600)
      at org.apache.openjpa.lib.conf.ConfigurationImpl.loadGlobals(ConfigurationImpl.java:191)
      at org.apache.openjpa.conf.OpenJPAConfigurationImpl.<init>(OpenJPAConfigurationImpl.java:584)
      at org.apache.openjpa.conf.OpenJPAConfigurationImpl.<init>(OpenJPAConfigurationImpl.java:195)
      at org.apache.openjpa.conf.OpenJPAConfigurationImpl.<init>(OpenJPAConfigurationImpl.java:186)
      at org.apache.openjpa.persistence.PersistenceProviderImpl.newConfigurationImpl(PersistenceProviderImpl.java:230)
      at org.apache.openjpa.persistence.PersistenceProviderImpl.createContainerEntityManagerFactory(PersistenceProviderImpl.java:166)
      at org.apache.openjpa.persistence.PersistenceProviderImpl.createContainerEntityManagerFactory(PersistenceProviderImpl.java:62)
      at org.apache.aries.jpa.container.impl.EntityManagerFactoryManager.createEntityManagerFactories(EntityManagerFactoryManager.java:227)
      at org.apache.aries.jpa.container.impl.EntityManagerFactoryManager.bundleStateChange(EntityManagerFactoryManager.java:121)
      at org.apache.aries.jpa.container.impl.PersistenceBundleManager.modifiedBundle(PersistenceBundleManager.java:197)
      at org.apache.aries.util.tracker.MultiBundleTracker$InternalBundleTracker.modifiedBundle(MultiBundleTracker.java:108)
      at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:453)
      at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:237)
      at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:413)
      at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:916)
      at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:220)
      at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:149)
      at org.eclipse.osgi.framework.internal.core.Framework.publishBundleEventPrivileged(Framework.java:1350)
      at org.eclipse.osgi.framework.internal.core.Framework.publishBundleEvent(Framework.java:1301)
      at org.eclipse.osgi.framework.internal.core.BundleHost.stopWorker(BundleHost.java:490)
      at org.eclipse.osgi.framework.internal.core.AbstractBundle.suspend(AbstractBundle.java:546)
      at org.eclipse.osgi.framework.internal.core.Framework.suspendBundle(Framework.java:1098)
      at org.eclipse.osgi.framework.internal.core.PackageAdminImpl.suspendBundle(PackageAdminImpl.java:314)
      at org.eclipse.osgi.framework.internal.core.PackageAdminImpl.processDelta(PackageAdminImpl.java:460)
      at org.eclipse.osgi.framework.internal.core.PackageAdminImpl.doResolveBundles(PackageAdminImpl.java:241)
      at org.eclipse.osgi.framework.internal.core.PackageAdminImpl$1.run(PackageAdminImpl.java:176)
      at java.lang.Thread.run(Thread.java:735)
      Caused by: java.lang.ClassNotFoundException: serp.util.Strings
      at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:489)
      at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:405)
      at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:393)
      at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:105)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:609)
      ... 34 more

      Obviously there is no problem if the package imports are satisfied, but it would be nice to have a clear error message indicating that no container-managed JPA is possible without these packages.

      Attachments

        1. OPENJPA-1490.diff
          1 kB
          Donald Woods

        Activity

          People

            Unassigned Unassigned
            timothyjward Timothy James Ward
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: