Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PGBundleActivator class issues on OpenJ9 #2133

Closed
rick-r3 opened this issue Apr 22, 2021 · 8 comments · Fixed by #507
Closed

PGBundleActivator class issues on OpenJ9 #2133

rick-r3 opened this issue Apr 22, 2021 · 8 comments · Fixed by #507

Comments

@rick-r3
Copy link

rick-r3 commented Apr 22, 2021

PGBundleActivator checks the content of the NoClassDefFoundError message as the basis of a condition. In OpenJ9 Java 11 JVMs (https://www.eclipse.org/openj9/) this condition is no longer met and thus does not function.

the condition is:

msg.contains("org/osgi/service/jdbc/DataSourceFactory")

Unfortunately OpenJ9 uses the class name with "." separators rather than "/" separators, and so in reality this condition needs to be:

(msg.contains("org/osgi/service/jdbc/DataSourceFactory") || msg.contains("org.osgi.service.jdbc.DataSourceFactory"))

I considered reporting this to OpenJ9, but I note that even HotSpot JVMs throw NoClassDefFoundErrors with "." rather than "/" (see source for ClassLoader.defineClass()) under some circumstances so best to be defensive against JVM inconsistencies.

We are specifically using 42.2.18, but suspect affects all versions.

OpenJ9 version: jdk-11.0.10+9_openj9-0.24.0 from AdoptOpenJDK (https://adoptopenjdk.net/releases.html?variant=openjdk11&jvmVariant=openj9)

@davecramer
Copy link
Member

What is the spec ?

@rick-r3
Copy link
Author

rick-r3 commented Apr 22, 2021

Of NoClassDefFoundError ?

@davecramer
Copy link
Member

where it says how to create the message correctly.

@rick-r3
Copy link
Author

rick-r3 commented Apr 22, 2021

It does not appear to be specified what the message is anywhere. The javadocs for NoClassDefFoundError only describe it as the "the detail message", with no other specification.

I noted an error in my report which is that it is ClassLoader.preDefineClass() (which is called from defineClass()) that throws NoClassDefFoundError with "." rather than "/" even on hotspot, as it uses the class name like so:

throw new NoClassDefFoundError("IllegalName: " + name);

@adelel1
Copy link

adelel1 commented Apr 27, 2021

Hello,
Do you have any update on this issue please.
I have raised a PR for the issue #2141
Thanks,

@adelel1
Copy link

adelel1 commented May 4, 2021

Hello, Is there an update on this please? The PR contains my latest update following the comments.
The issue is a showstopper for us, Postgres fails on openj9 with OSGi.
Thanks,

@davecramer
Copy link
Member

Apologies. I'll have a look at this today

@vlsi
Copy link
Member

vlsi commented May 8, 2021

I've reworked OSGi tests in #507, and it allows running OSGi tests as a part of pgjdbc test suite.

The takeaways are:

  1. There's no need to analyze exception message. The implementation should call Class.forName("...DataSourceFactory") and watch for ClassNotFoundException. That is reliable

  2. The driver should not try to register DataSourceFactory. The factory should be registered as a part of https://github.com/ops4j/org.ops4j.pax.jdbc. The ones who need the factory would install pax-jdbc-pgjdbc and that is it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants