Root exception not accessible

127 views
Skip to first unread message

Jérôme LELEU

unread,
Apr 3, 2014, 3:05:56 PM4/3/14
to ldap...@googlegroups.com
Hi,

I thought I posted this question already but I can't find it in the mailing list.

Anyway, I think I've found an issue in ldaptive: when a problem occurs, the root exception is never reported back to the original call.

Let's take an example: I'm setting my ldap url to ldap://bidon, which will obviously not work.

When creating a BlockinConnectionPool, I get an IllegalStateException with the message: "Could not initialize pool size" and with no root cause.

Though, I can see in my logs that the problem comes from the url: 
ERROR  o.l.p.BlockingConnectionPool - unable to connect to the ldap java.net.MalformedURLException: Not an LDAP URL: ladp://bidon
at com.sun.jndi.ldap.LdapURL.<init>(Unknown Source) ~[na:1.7.0_51]
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(Unknown Source) ~[na:1.7.0_51]
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(Unknown Source) ~[na:1.7.0_51]
at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(Unknown Source) ~[na:1.7.0_51]
at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(Unknown Source) ~[na:1.7.0_51]
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source) ~[na:1.7.0_51]
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source) ~[na:1.7.0_51]
at javax.naming.InitialContext.init(Unknown Source) ~[na:1.7.0_51]
at javax.naming.ldap.InitialLdapContext.<init>(Unknown Source) ~[na:1.7.0_51]
Wrapped by: javax.naming.NamingException: Cannot parse url: ladp://bidon
at com.sun.jndi.ldap.LdapURL.<init>(Unknown Source) ~[na:1.7.0_51]
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(Unknown Source) ~[na:1.7.0_51]
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(Unknown Source) ~[na:1.7.0_51]
at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(Unknown Source) ~[na:1.7.0_51]
at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(Unknown Source) ~[na:1.7.0_51]
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source) ~[na:1.7.0_51]
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source) ~[na:1.7.0_51]
at javax.naming.InitialContext.init(Unknown Source) ~[na:1.7.0_51]
at javax.naming.ldap.InitialLdapContext.<init>(Unknown Source) ~[na:1.7.0_51]
Wrapped by: org.ldaptive.provider.ConnectionException: javax.naming.NamingException: Cannot parse url: ladp://bidon [Root exception is java.net.MalformedURLException: Not an LDAP URL: ladp://bidon]
at org.ldaptive.provider.jndi.JndiConnectionFactory.createInternal(JndiConnectionFactory.java:86) ~[ldaptive-1.0.3-SNAPSHOT.jar:na]
at org.ldaptive.provider.jndi.JndiConnectionFactory.createInternal(JndiConnectionFactory.java:31) ~[ldaptive-1.0.3-SNAPSHOT.jar:na]
at org.ldaptive.provider.AbstractProviderConnectionFactory.create(AbstractProviderConnectionFactory.java:118) ~[ldaptive-1.0.3-SNAPSHOT.jar:na]
at org.ldaptive.DefaultConnectionFactory$DefaultConnection.open(DefaultConnectionFactory.java:295) ~[ldaptive-1.0.3-SNAPSHOT.jar:na]
at org.ldaptive.pool.AbstractConnectionPool.createConnection(AbstractConnectionPool.java:432) [ldaptive-1.0.3-SNAPSHOT.jar:na]
at org.ldaptive.pool.AbstractConnectionPool.createAvailableConnection(AbstractConnectionPool.java:453) [ldaptive-1.0.3-SNAPSHOT.jar:na]
at org.ldaptive.pool.AbstractConnectionPool.grow(AbstractConnectionPool.java:337) [ldaptive-1.0.3-SNAPSHOT.jar:na]
at org.ldaptive.pool.AbstractConnectionPool.initialize(AbstractConnectionPool.java:249) [ldaptive-1.0.3-SNAPSHOT.jar:na]

Is there a way to get the root exception? Am I doing something wrong?

Thanks.
Best regards,
Jérôme

dfisher

unread,
Apr 3, 2014, 3:32:23 PM4/3/14
to ldap...@googlegroups.com
Exceptions encountered by individual connections are logged at error level, but they are not thrown to the caller.
Sounds like you have a use case for handling different exception types from initialize?

--Daniel Fisher

Jérôme LELEU

unread,
Apr 5, 2014, 5:57:12 AM4/5/14
to ldap...@googlegroups.com
Hi,

I created a UI for users to define their own LDAP configuration and I have a "Test connection" button, which tries to initialize a connection. And I'd like to report back to the user with the appropriate error message the cause of the initialization failure.

The problem happens in the createConnection method, when trying to r = c.open();, the catched exception is not thrown, nor kept. An IllegalStateException could be thrown here.

Thanks.
Best regards,
Jérôme

dfisher

unread,
Apr 7, 2014, 10:45:56 AM4/7/14
to ldap...@googlegroups.com

Note that throwing from the open() attempt isn't an option because a single connection failure doesn't necessarily mean the pool cannot initialize.
You could get a variety of issues with each connection if you're having network troubles.

I think the fix here is a custom exception class that contains all the exceptions thrown.
You could then pull that out of the IllegalStateException.

Are you interested in exceptions that occurred even if the pool was able to successfully initialize?

--Daniel Fisher

Jérôme LELEU

unread,
Apr 7, 2014, 2:11:59 PM4/7/14
to ldap...@googlegroups.com
Hi,

Indeed, you're right: there are multiple initialization attempts.
In my use case, I'm only interested by the fact that all connections have failed.
Thanks.
Best regards,
Jérôme



--
You received this message because you are subscribed to a topic in the Google Groups "ldaptive" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ldaptive/utM4LOmCx40/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ldaptive+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages