ops4j / org.ops4j.pax.transx

Transaction Manager and JMS / JDBC pooling support
Apache License 2.0
8 stars 7 forks source link

pax-transx-tm-narayana bundle not useable with JDK 11 #50

Closed graben closed 3 years ago

graben commented 3 years ago

pax-transx-tm-narayana needs explicit import for javax.security.cert to get used under JDK 11. It's usable with JDK 8 even without import.

Caused by: java.lang.ClassNotFoundException: javax.security.cert.X509Certificate
    at java.net.URLClassLoader.findClass(URLClassLoader.java:471) ~[?:?]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:589) ~[?:?]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[?:?]
    at io.netty.util.internal.EmptyArrays.<clinit>(EmptyArrays.java:38) ~[netty-common-4.1.48.Final.jar:4.1.48.Final]
    at io.netty.util.ResourceLeakDetector.<clinit>(ResourceLeakDetector.java:564) ~[netty-common-4.1.48.Final.jar:4.1.48.Final]
    at io.netty.buffer.AbstractByteBufAllocator.<clinit>(AbstractByteBufAllocator.java:36) ~[netty-buffer-4.1.48.Final.jar:4.1.48.Final]
    at io.netty.buffer.Unpooled.<clinit>(Unpooled.java:74) ~[netty-buffer-4.1.48.Final.jar:4.1.48.Final]
    at org.apache.activemq.artemis.core.io.buffer.TimedBuffer.<init>(TimedBuffer.java:126) ~[artemis-journal-2.14.0.jar:2.14.0]
    at org.apache.activemq.artemis.core.io.AbstractSequentialFileFactory.<init>(AbstractSequentialFileFactory.java:92) ~[artemis-journal-2.14.0.jar:2.14.0]
    at org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory.<init>(NIOSequentialFileFactory.java:78) ~[artemis-journal-2.14.0.jar:2.14.0]
    at org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory.<init>(NIOSequentialFileFactory.java:67) ~[artemis-journal-2.14.0.jar:2.14.0]
    at com.arjuna.ats.internal.arjuna.objectstore.hornetq.HornetqJournalStore.<init>(HornetqJournalStore.java:133) ~[arjuna-5.10.6.Final.jar:5.10.6.Final]
    at com.arjuna.ats.internal.arjuna.objectstore.hornetq.HornetqObjectStoreAdaptor.<init>(HornetqObjectStoreAdaptor.java:84) ~[arjuna-5.10.6.Final.jar:5.10.6.Final]
grgrzybek commented 3 years ago

Thanks for finding this. I see Karaf doesn't add javax.security.cert to org.osgi.framework.bootdelegation...

graben commented 3 years ago

Do you think it's more a Karaf bug?

grgrzybek commented 3 years ago

I'm just running pax-transx tests on JDK11 and they hang at org.ops4j.pax.transx.itests.NarayanaRecoveryTest - may be on my side, but let me check further.

grgrzybek commented 3 years ago

javax.security.cert should rather be explicitly imported - I wonder why only on JDK11 and why it wasn't caught by maven-bundle-plugin

grgrzybek commented 3 years ago

JDK8 tests pass:

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running org.ops4j.pax.transx.itests.AtomikosRecoveryTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.595 s - in org.ops4j.pax.transx.itests.AtomikosRecoveryTest
[INFO] Running org.ops4j.pax.transx.itests.AtomikosTest
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.956 s - in org.ops4j.pax.transx.itests.AtomikosTest
[INFO] Running org.ops4j.pax.transx.itests.GenericConnectionManagerTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.683 s - in org.ops4j.pax.transx.itests.GenericConnectionManagerTest
[INFO] Running org.ops4j.pax.transx.itests.GeronimoRecoveryTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.865 s - in org.ops4j.pax.transx.itests.GeronimoRecoveryTest
[INFO] Running org.ops4j.pax.transx.itests.GeronimoTest
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.931 s - in org.ops4j.pax.transx.itests.GeronimoTest
[INFO] Running org.ops4j.pax.transx.itests.NarayanaRecoveryTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.848 s - in org.ops4j.pax.transx.itests.NarayanaRecoveryTest
[INFO] Running org.ops4j.pax.transx.itests.NarayanaTest
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.725 s - in org.ops4j.pax.transx.itests.NarayanaTest
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 12, Failures: 0, Errors: 0, Skipped: 0
graben commented 3 years ago

I'm just running pax-transx tests on JDK11 and they hang at org.ops4j.pax.transx.itests.NarayanaRecoveryTest - may be on my side, but let me check further.

Yes I had the same problem. Have a look into org.ops4j.pax.transx\pax-transx-itests\target\surefire-reports\org.ops4j.pax.transx.itests.NarayanaRecoveryTest-output.txt its weird JDK stuff :)

grgrzybek commented 3 years ago

Here's the problem:

java.lang.NoClassDefFoundError: jdk/internal/reflect/ConstructorAccessorImpl
    at java.base/jdk.internal.misc.Unsafe.defineClass0(Native Method)
    at java.base/jdk.internal.misc.Unsafe.defineClass(Unsafe.java:1194)
    at java.base/jdk.internal.reflect.ClassDefiner.defineClass(ClassDefiner.java:63)
    at java.base/jdk.internal.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:400)
    at java.base/jdk.internal.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:394)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/jdk.internal.reflect.MethodAccessorGenerator.generate(MethodAccessorGenerator.java:393)
    at java.base/jdk.internal.reflect.MethodAccessorGenerator.generateConstructor(MethodAccessorGenerator.java:92)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:55)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at java.base/java.lang.reflect.Proxy.newProxyInstance(Proxy.java:1022)
    at java.base/java.lang.reflect.Proxy.newProxyInstance(Proxy.java:1008)
    at java.base/sun.reflect.annotation.AnnotationParser$1.run(AnnotationParser.java:306)
    at java.base/sun.reflect.annotation.AnnotationParser$1.run(AnnotationParser.java:304)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/sun.reflect.annotation.AnnotationParser.annotationForMap(AnnotationParser.java:304)
    at java.base/sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:294)
    at java.base/sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:121)
    at java.base/sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:73)
    at java.base/java.lang.reflect.Field.declaredAnnotations(Field.java:1175)
    at java.base/java.lang.reflect.Field.declaredAnnotations(Field.java:1173)
    at java.base/java.lang.reflect.Field.getAnnotation(Field.java:1142)
    at java.base/java.lang.reflect.AnnotatedElement.isAnnotationPresent(AnnotatedElement.java:274)
    at java.base/java.lang.reflect.AccessibleObject.isAnnotationPresent(AccessibleObject.java:517)
    at com.arjuna.common.internal.util.propertyservice.BeanPopulator.configureFromProperties(BeanPopulator.java:169)
    at com.arjuna.common.internal.util.propertyservice.BeanPopulator.getNamedInstance(BeanPopulator.java:87)
    at com.arjuna.common.internal.util.propertyservice.BeanPopulator.getNamedInstance(BeanPopulator.java:66)
    at com.arjuna.ats.arjuna.objectstore.StoreManager.initStore(StoreManager.java:146)
    at com.arjuna.ats.arjuna.objectstore.StoreManager.getActionStore(StoreManager.java:111)
    at com.arjuna.ats.arjuna.objectstore.StoreManager.getRecoveryStore(StoreManager.java:68)
    at com.arjuna.ats.internal.arjuna.recovery.AtomicActionRecoveryModule.<init>(AtomicActionRecoveryModule.java:67)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at java.base/java.lang.Class.newInstance(Class.java:584)
    at com.arjuna.common.internal.util.ClassloadingUtility.loadAndInstantiateClass(ClassloadingUtility.java:135)
    at com.arjuna.common.internal.util.ClassloadingUtility.loadAndInstantiateClassesWithInit(ClassloadingUtility.java:192)
    at com.arjuna.ats.arjuna.common.RecoveryEnvironmentBean.getRecoveryModules(RecoveryEnvironmentBean.java:465)
    at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.loadModules(PeriodicRecovery.java:888)
    at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.<init>(PeriodicRecovery.java:121)
    at com.arjuna.ats.internal.arjuna.recovery.RecoveryManagerImple.<init>(RecoveryManagerImple.java:107)
    at com.arjuna.ats.arjuna.recovery.RecoveryManager.<init>(RecoveryManager.java:481)
    at com.arjuna.ats.arjuna.recovery.RecoveryManager.manager(RecoveryManager.java:132)
    at com.arjuna.ats.arjuna.recovery.RecoveryManager.manager(RecoveryManager.java:112)
    at com.arjuna.ats.jbossatx.jta.RecoveryManagerService.create(RecoveryManagerService.java:54)
    at org.jboss.narayana.osgi.jta.internal.OsgiServer.doStart(OsgiServer.java:89)
    at org.jboss.narayana.osgi.jta.internal.OsgiServer.start(OsgiServer.java:66)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.jboss.narayana.osgi.jta.internal.Activator.doStart(Activator.java:49)
    at org.ops4j.pax.transx.tm.impl.AbstractActivator.run(AbstractActivator.java:115)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.ClassNotFoundException: jdk.internal.reflect.ConstructorAccessorImpl
    at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    ... 60 more
grgrzybek commented 3 years ago

See https://issues.apache.org/jira/browse/FELIX-6184

grgrzybek commented 3 years ago

Hmm, netty-common has proper import of javax.security.cert;resolution:=optional. I see that pax-transx-tm-narayana activator creates some magical classloader, but it doesn't look like JDK dependent...

@graben from the stack trace fragment:

Caused by: java.lang.ClassNotFoundException: javax.security.cert.X509Certificate
    at java.net.URLClassLoader.findClass(URLClassLoader.java:471) ~[?:?]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:589) ~[?:?]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[?:?]
    at io.netty.util.internal.EmptyArrays.<clinit>(EmptyArrays.java:38) ~[netty-common-4.1.48.Final.jar:4.1.48.Final]

it looks like exactly this class loader is used: https://github.com/ops4j/org.ops4j.pax.transx/blob/pax-transx-0.5.0/pax-transx-tm-narayana/src/main/java/org/jboss/narayana/osgi/jta/internal/Activator.java#L87-L97 - I'll try to reproduce it tomorrow, ok?

graben commented 3 years ago

What do you expect? It's working with my small patch #51, but maybe a better solution could be found. I have no pressure at the moment. :)

grgrzybek commented 3 years ago

I'm rather worried that there may be other missing packages ;) And because netty-common has this import, javax.security.cert.X509Certificate should be loaded through netty-common's BundleClassLoader

grgrzybek commented 3 years ago

I added a simple test to pax-transx-tm-narayana to check the imports of the bundles that are embedded inside pax-transx-tm-narayana and are used within special ClassLoader. Then I removed these imports, which are satisfied by the exports of the embedded bundles.

The result is:

= netty-handler-4.1.48.Final.jar
Import-Package
 - io.netty.internal.tcnative;resolution:=optional
 - javax.crypto
 - javax.crypto.spec
 - javax.net.ssl
 - javax.security.auth.x500
 - javax.security.cert
 - org.bouncycastle.asn1.x500;resolution:=optional
 - org.bouncycastle.cert;resolution:=optional
 - org.bouncycastle.cert.jcajce;resolution:=optional
 - org.bouncycastle.jce.provider;resolution:=optional
 - org.bouncycastle.operator;resolution:=optional
 - org.bouncycastle.operator.jcajce;resolution:=optional
 - org.conscrypt;resolution:=optional
 - org.eclipse.jetty.alpn;resolution:=optional
 - org.eclipse.jetty.npn;resolution:=optional
 - sun.nio.ch;resolution:=optional
 - sun.security.util;resolution:=optional
 - sun.security.x509;resolution:=optional
= jtax-5.10.6.Final.jar
Import-Package
= netty-codec-4.1.48.Final.jar
Import-Package
 - com.google.protobuf;resolution:=optional
 - com.google.protobuf.nano;resolution:=optional
 - com.jcraft.jzlib;resolution:=optional
 - com.ning.compress;resolution:=optional
 - com.ning.compress.lzf;resolution:=optional
 - com.ning.compress.lzf.util;resolution:=optional
 - lzma.sdk;resolution:=optional
 - lzma.sdk.lzma;resolution:=optional
 - net.jpountz.lz4;resolution:=optional
 - net.jpountz.xxhash;resolution:=optional
 - org.eclipse.jetty.alpn;resolution:=optional
 - org.eclipse.jetty.npn;resolution:=optional
 - org.jboss.marshalling;resolution:=optional
 - sun.nio.ch;resolution:=optional
= netty-common-4.1.48.Final.jar
Import-Package
 - com.oracle.svm.core.annotate;resolution:=optional
 - javax.security.cert;resolution:=optional
 - org.apache.commons.logging;resolution:=optional
 - org.apache.log4j;resolution:=optional
 - org.apache.logging.log4j;resolution:=optional
 - org.apache.logging.log4j.message;resolution:=optional
 - org.apache.logging.log4j.spi;resolution:=optional
 - org.slf4j;resolution:=optional
 - org.slf4j.helpers;resolution:=optional
 - org.slf4j.spi;resolution:=optional
 - reactor.blockhound;resolution:=optional
 - reactor.blockhound.integration;resolution:=optional
 - sun.misc;resolution:=optional
= artemis-commons-2.14.0.jar
Import-Package
= activemq-artemis-native-1.0.2.jar
Import-Package
= artemis-journal-2.14.0.jar
Import-Package
= netty-transport-4.1.48.Final.jar
Import-Package
 - org.eclipse.jetty.alpn;resolution:=optional
 - org.eclipse.jetty.npn;resolution:=optional
 - sun.nio.ch;resolution:=optional
= jboss-logging-3.2.1.Final.jar
Import-Package
 - org.apache.log4j;resolution:=optional
 - org.apache.logging.log4j;resolution:=optional
 - org.apache.logging.log4j.message
 - org.apache.logging.log4j.spi
 - org.jboss.logmanager;resolution:=optional
 - org.slf4j;resolution:=optional
 - org.slf4j.spi;resolution:=optional
= jta-5.10.6.Final.jar
Import-Package
= arjuna-5.10.6.Final.jar
Import-Package
= common-5.10.6.Final.jar
Import-Package
= netty-buffer-4.1.48.Final.jar
Import-Package
 - org.eclipse.jetty.alpn;resolution:=optional
 - org.eclipse.jetty.npn;resolution:=optional
 - sun.nio.ch;resolution:=optional
= orbportability-5.10.6.Final.jar
Import-Package
= narayana-jts-integration-5.10.6.Final.jar
Import-Package
= netty-resolver-4.1.48.Final.jar
Import-Package
 - org.eclipse.jetty.alpn;resolution:=optional
 - org.eclipse.jetty.npn;resolution:=optional
 - sun.nio.ch;resolution:=optional

I'll add relevant imports to pax-transx-tm-narayana itself

grgrzybek commented 3 years ago

Tests pass in JDK8 and JDK11.

graben commented 3 years ago

@grgrzybek : Time to release 0.5.1?

grgrzybek commented 3 years ago

sure - let me do it on Monday, ok? And sorry for the delay ;)

jbonofre commented 3 years ago

I can do it during Week end if you want. Just let me know.

graben commented 3 years ago

Monday is fine :-)

grgrzybek commented 3 years ago

I'm just releasing pax-transx 0.5.1