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

java.lang.reflect.UndeclaredThrowableException with spring-ldap-core 2.3.2.RELEASE and above #660

Open
aplatt opened this issue May 16, 2022 · 2 comments
Assignees
Labels
Milestone

Comments

@aplatt
Copy link

aplatt commented May 16, 2022

I am using the following version of Java:

openjdk version "1.8.0_312"
OpenJDK Runtime Environment (build 1.8.0_312-8u312-b07-0ubuntu1~18.04-b07)
OpenJDK 64-Bit Server VM (build 25.312-b07, mixed mode)

When I make the following lookup using StartTLS with spring-ldap-core 2.3.1.RELEASE for a non existent dn:

DefaultTlsDirContextAuthenticationStrategy tlsAuthStratagy = new DefaultTlsDirContextAuthenticationStrategy();
tlsAuthStratagy.setShutdownTlsGracefully(true);
contextSource.setAuthenticationStrategy(tlsAuthStratagy);
PoolingContextSource poolingContextSource = new PoolingContextSource();
poolingContextSource.setMaxActive(5);
poolingContextSource.setContextSource(contextSource);
proxy = new TransactionAwareContextSourceProxy(poolingContextSource);
LdapTemplate ldapTemplate = new LdapTemplate(proxy);
ldapTemplate.lookup(dn);

I receive the following exception as expected:

org.springframework.ldap.NameNotFoundException

However, from spring-ldap-core 2.3.2.RELEASE and above, I received the following exception:

java.lang.reflect.UndeclaredThrowableException

This only happens when I attempt to use StartTLS ie. call setAuthenticationStrategy().

@jzheaux
Copy link
Contributor

jzheaux commented Jan 19, 2023

Thanks for the report, @aplatt. The only commit I can see between those two releases that may be related is c0def85.

I have not been able to reproduce this yet, though I imagine it has something to do with the above arrangement is propagating exceptions. Does the UndeclaredThrowableException have a caused by or anything else that indicates what its cause is? Or, are you able to produce a GitHub sample that demonstrates the error?

@jzheaux jzheaux self-assigned this Jan 19, 2023
@jzheaux jzheaux added type: bug A general bug in: core labels Jan 19, 2023
@jzheaux jzheaux added this to the 2.3.9 milestone Jan 19, 2023
@aplatt
Copy link
Author

aplatt commented Jan 23, 2023

Yes, the cause is actually the exception that was thrown prior to spring-ldap-core 2.3.2.RELEASE. It appears that all the LDAP exceptions thrown prior to spring-ldap-core 2.3.2.RELEASE have been translated to java.lang.reflect.UndeclaredThrowableException exceptions with the cause being the original exception. Only when using StartTLS (see original code snippet above).

Caused by: javax.naming.NameNotFoundException: [LDAP: error code 32 - No Such Object]
at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3286)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:3207)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2998)
at com.sun.jndi.ldap.LdapCtx.c_rename(LdapCtx.java:755)
at com.sun.jndi.toolkit.ctx.ComponentContext.p_rename(ComponentContext.java:709)
at com.sun.jndi.toolkit.ctx.PartialCompositeContext.rename(PartialCompositeContext.java:269)
at javax.naming.InitialContext.rename(InitialContext.java:455)

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

No branches or pull requests

2 participants