You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When this code runs in a Maven plugin, this fails with
javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.jndi.dns.DnsContextFactory [Root exception is java.lang.IllegalAccessException: class javax.naming.spi.NamingManager (in module java.naming) cannot access class com.sun.jndi.dns.DnsContextFactory (in module jdk.naming.dns) because module jdk.naming.dns does not export com.sun.jndi.dns to module java.naming]
When I run the same code directly as a Java application, with the same JVM options, classpath etc., it works fine. I suspect that this has something to do with the plexus-classworlds classloader system, but I'm at a loss what, why and how.
Interesting enough, if I run Maven with MAVEN_OPTS="--add-opens jdk.naming.dns/com.sun.jndi.dns=java.naming", it works, even though that should not be necessary.
I'm not quite sure where to place this bug - here, with Maven, with Netty, or with the affected Maven plugin. So I'm going to start here...
I am using the
apicurio-registry-maven-plugin
in my Maven build with Java 21.Under the hood, this uses Netty. Under Windows, Netty uses JNDI to get the system DNS servers, essentially doing this:
When this code runs in a Maven plugin, this fails with
When I run the same code directly as a Java application, with the same JVM options, classpath etc., it works fine. I suspect that this has something to do with the plexus-classworlds classloader system, but I'm at a loss what, why and how.
System:
Windows 11
OpenJDK 21.0.5 (Eclipse Temurin-21.0.5+11)
Maven 3.9.9
apicurio-registry-maven-plugin 3.0.4
Netty 4.1.111
The text was updated successfully, but these errors were encountered: