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

Ldap style oracle jdbc urls not supported for native #19057

Closed
vsevel opened this issue Jul 28, 2021 · 4 comments · Fixed by #22452
Closed

Ldap style oracle jdbc urls not supported for native #19057

vsevel opened this issue Jul 28, 2021 · 4 comments · Fixed by #22452
Labels
kind/bug Something isn't working
Milestone

Comments

@vsevel
Copy link
Contributor

vsevel commented Jul 28, 2021

Describe the bug

If I use a url jdbc:oracle:thin:@ldap://..., I get the following error at startup: java.lang.ClassNotFoundException: com.sun.jndi.ldap.LdapCtxFactory]

Expected behavior

Should work same as non ldap oracle jdbc url.

Actual behavior

Here is the full exception:

 --/ __ \/ / / / _ | / _ \/ //_/ / / / __/
 -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2021-07-28 11:51:47,444 WARN  [io.agr.pool] (agroal-11) Datasource '<default>': IO Error: JNDI Package failure javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.jndi.ldap.LdapCtxFactory [Root exception is java.lang.ClassNotFoundException: com.sun.jndi.ldap.LdapCtxFactory] (CONNECTION_ID=yh0svrfuQK+prg+PVtb/mw==)
2021-07-28 11:51:47,445 WARN  [org.hib.eng.jdb.env.int.JdbcEnvironmentInitiator] (JPA Startup Thread: <default>) HHH000342: Could not obtain connection to query metadata: java.sql.SQLRecoverableException: IO Error: JNDI Package failure javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.jndi.ldap.LdapCtxFactory [Root exception is java.lang.ClassNotFoundException: com.sun.jndi.ldap.LdapCtxFactory] (CONNECTION_ID=yh0svrfuQK+prg+PVtb/mw==)
        at oracle.jdbc.driver.T4CConnection.handleLogonNetException(T4CConnection.java:870)
        at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:675)
        at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:1032)
        at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:90)
        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:681)
        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:602)
        at io.agroal.pool.ConnectionFactory.createConnection(ConnectionFactory.java:204)
        at io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPool.java:470)
        at io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPool.java:452)
        at java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at io.agroal.pool.util.PriorityScheduledExecutor.beforeExecute(PriorityScheduledExecutor.java:68)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1126)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.lang.Thread.run(Thread.java:829)
        at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:553)
        at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
Caused by: oracle.net.ns.NetException: JNDI Package failure javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.jndi.ldap.LdapCtxFactory [Root exception is java.lang.ClassNotFoundException: com.sun.jndi.ldap.LdapCtxFactory] (CONNECTION_ID=yh0svrfuQK+prg+PVtb/mw==)
        at oracle.net.jndi.JndiAttrs.initializeLDAPContext(JndiAttrs.java:290)
        at oracle.net.jndi.JndiAttrs.<init>(JndiAttrs.java:165)
        at oracle.net.resolver.AddrResolution.<init>(AddrResolution.java:334)
        at oracle.net.ns.NSProtocol.connect(NSProtocol.java:329)
        at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1967)
        at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:640)
        ... 14 more
Caused by: javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.jndi.ldap.LdapCtxFactory [Root exception is java.lang.ClassNotFoundException: com.sun.jndi.ldap.LdapCtxFactory]
        at javax.naming.spi.NamingManager.getFactory(NamingManager.java:760)
        at javax.naming.spi.NamingManager.lambda$getInitialContext$1(NamingManager.java:722)
        at jdk.internal.loader.AbstractClassLoaderValue$Memoizer.get(AbstractClassLoaderValue.java:329)
        at jdk.internal.loader.AbstractClassLoaderValue.computeIfAbsent(AbstractClassLoaderValue.java:205)
        at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:722)
        at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:305)
        at javax.naming.InitialContext.init(InitialContext.java:236)
        at javax.naming.InitialContext.<init>(InitialContext.java:208)
        at javax.naming.directory.InitialDirContext.<init>(InitialDirContext.java:101)
        at oracle.net.jndi.JndiAttrs.initializeLDAPContext(JndiAttrs.java:282)
        ... 19 more
Caused by: java.lang.ClassNotFoundException: com.sun.jndi.ldap.LdapCtxFactory
        at com.oracle.svm.core.hub.ClassForNameSupport.forName(ClassForNameSupport.java:64)
        at java.lang.Class.forName(DynamicHub.java:1308)
        at com.sun.naming.internal.VersionHelper.loadClass(VersionHelper.java:127)
        at com.sun.naming.internal.VersionHelper.loadClass(VersionHelper.java:133)
        at com.sun.naming.internal.VersionHelper.loadClass(VersionHelper.java:96)
        at javax.naming.spi.NamingManager.getFactory(NamingManager.java:757)
        ... 28 more

How to Reproduce?

Create an application using the quarkus-jdbc-oracle driver.
Compile the application in native.
Run the application with a url of type: quarkus.datasource.jdbc.url=jdbc:oracle:thin:@ldap://....
The application fails at startup.

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

GraalVM 21.1.0 Java 11 CE (Java Version 11.0.11+8-jvmci-21.1-b05)

Quarkus version or git rev

2.1.0

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

Note that the application works with tns style url: quarkus.datasource.jdbc.url=jdbc:oracle:thin:@(DESCRIPTION=(ENABLE=BROKEN)(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)... (the address resolved by ldap).
So the issue is really about ldap access, not oracle.

@vsevel vsevel added the kind/bug Something isn't working label Jul 28, 2021
@vsevel
Copy link
Contributor Author

vsevel commented Nov 30, 2021

could this be linked to #18385?

@matthyx
Copy link

matthyx commented Dec 1, 2021

@gsmet I have a similar issue with the following trace:

Caused by: java.lang.ClassNotFoundException: com.sun.jndi.ldap.LdapCtxFactory
at com.oracle.svm.core.hub.ClassForNameSupport.forName(ClassForNameSupport.java:64)
at java.lang.Class.forName(DynamicHub.java:1308)
at com.sun.naming.internal.VersionHelper.loadClass(VersionHelper.java:127)
at com.sun.naming.internal.VersionHelper.loadClass(VersionHelper.java:133)
at com.sun.naming.internal.VersionHelper.loadClass(VersionHelper.java:96)
at javax.naming.spi.NamingManager.getFactory(NamingManager.java:757)
... 28 more

Can someone knowledgeable have a look, please?

@vsevel
Copy link
Contributor Author

vsevel commented Dec 20, 2021

this can be solved using @RegisterForReflection(classNames = { "com.sun.jndi.ldap.LdapCtxFactory" })

@gsmet
Copy link
Member

gsmet commented Dec 21, 2021

It's going to be fixed in 2.6.1.Final thanks to #22452 .

@gsmet gsmet modified the milestones: 2.7 - main, 2.6.1.Final Dec 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants