Reputation:
tl;dr:
long version: We are currently trying to create OSGi bundles from all our 3rd party libraries by basically using the bnd tools to repackage them. When (re)-packaging hibernate.org (5.3.7) we are facing a problem (java.lang.NoClassDefFoundError: javax/transaction/SystemException) with the import package directive of the hibernate.org library.
In our maven build we are running into a java.lang.NoClassDefFoundError when running the surefire plugin to execute our plug-in tests.
The partly reduced stacktrace from the Jenkins console log looks like this (indicating that the activation of a bundle using hibernate failed):
!ENTRY org.eclipse.osgi 4 0 2020-01-30 11:39:27.329!MESSAGE An error occurred while automatically activating bundle some.company.bundle (51).
!STACK 0
org.osgi.framework.BundleException: Exception in some.other.company.bundle.Activator.start() of bundle some.other.company.bundle
at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:803)
at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:732)
at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:1005)
at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:357)
at org.eclipse.osgi.container.Module.doStart(Module.java:588)
at org.eclipse.osgi.container.Module.start(Module.java:456)
at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:471)
at org.eclipse.osgi.internal.hooks.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:117)
at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:557)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:331)
at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:395)
at org.eclipse.osgi.internal.loader.sources.SingleSourcePackage.loadClass(SingleSourcePackage.java:39)
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:469)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:414)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:153)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at at some.other.company.bundle.AConstructorOfClassUsingHibernateStuff
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at some.other.company.bundle...
at some.other.company.bundle...
at some.other.company.bundle...
at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:782)
at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:1)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:775)
at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:732)
at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:1005)
at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:357)
at org.eclipse.osgi.container.Module.doStart(Module.java:588)
at org.eclipse.osgi.container.Module.start(Module.java:456)
at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:431)
at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:450)
at org.eclipse.tycho.surefire.osgibooter.OsgiSurefireBooter.getBundleClassLoader(OsgiSurefireBooter.java:179)
at org.eclipse.tycho.surefire.osgibooter.OsgiSurefireBooter.createCombinedClassLoader(OsgiSurefireBooter.java:117)
at org.eclipse.tycho.surefire.osgibooter.OsgiSurefireBooter.run(OsgiSurefireBooter.java:110)
at org.eclipse.tycho.surefire.osgibooter.HeadlessTestApplication.run(HeadlessTestApplication.java:21)
Caused by: java.lang.NoClassDefFoundError: javax/transaction/SystemException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.jboss.logging.Logger$1.run(Logger.java:2554)
at java.security.AccessController.doPrivileged(Native Method)
at org.jboss.logging.Logger.getMessageLogger(Logger.java:2529)
at org.jboss.logging.Logger.getMessageLogger(Logger.java:2516)
at org.hibernate.internal.CoreLogging.messageLogger(CoreLogging.java:28)
at org.hibernate.internal.CoreLogging.messageLogger(CoreLogging.java:24)
at org.hibernate.type.spi.TypeConfiguration.<clinit>(TypeConfiguration.java:59)
followed by the reason, why the activation failed
Caused by: java.lang.ClassNotFoundException: javax.transaction.SystemException cannot be found by org.hibernate_5.3.7.v20200129-1820
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:460)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:414)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:153)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
And yes, the class javax.transaction.SystemException does not exist in the org.hibernate_5.3.7.v20200129-1820.jar but in our/jboss' javax.transaction.jar. Therefore we put the javax.transaction.jar as an extraRequirements/requirement-entry to the tycho configuration, because transitive dependencies aren't resolved during test execution. But still, it appears the javax.transaction-package from the rt.jar is being preferred over the same package in our javax.transaction.jar.
The org.hibernate bundle has the following dependencies:
Upvotes: 8
Views: 367
Reputation: 2623
You have 3 questions in 1... But to provide a simple answer, you probably have >1 javax.transaction in your runtime, so get rid of the system one if you gonna provide a custom bundle for it.
You can try removing javax.transaction (and friends) from the packages in jre.properties
Upvotes: 0