WFNAM00003: Invalid naming provider URI ... URISyntaxException: Illegal character in path at index in JBoss EAP 7.1

Solution Verified - Updated

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 7

Issue

  • We have a property that contains LDAP URLs separated by spaces that was working before we changed it to use org.wildfly.naming.client.WildFlyInitialContextFactory
    in EAP 7.1. Now we are getting the exception below:
WFNAM00003: Invalid naming provider URI: ldaps://host1.net:389/ ldaps://host2.net:389/: javax.naming.ConfigurationException: WFNAM00003: Invalid naming provider URI: ldaps://host1.net:389/ ldaps://host2.net:389/ [Root exception is java.net.URISyntaxException: Illegal character in path at index 36: ldaps://host1.net:389/ ldaps://host2.net:389/]

Resolution

Change the application back to using the initial context factory: com.sun.jndi.ldap.LdapCtxFactory. The org.wildfly.naming.client.WildFlyInitialContextFactory does not handle LDAP, it handles http+remoting, http-remoting, remote protocols.

        Properties env = new Properties();
        env.put(DirContext.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
        env.put(DirContext.PROVIDER_URL, providerURLString);
        DirContext dc = new InitialDirContext(env);

Related Solutions

Root Cause

org.wildfly.naming.client.WildFlyInitialContextFactory does not handle the ldap protocol, com.sun.jndi.ldap.LdapCtxFactory handles the ldap protocol

Diagnostic Steps

WildFlyInitialContextFactory does not handle the ldap protocol, if the initial context provider URL is a ldap URL, this error will be logged:

     javax.naming.InvalidNameException: WFNAM00007: Invalid URL scheme name "ldap"
     	at org.wildfly.naming.client.WildFlyRootContext.getProviderContext(WildFlyRootContext.java:808)
...

WildFlyInitialContextFactory does not use a space as the delimiter between URLs in the provider URL, if a space is used it will log this error:

     javax.naming.ConfigurationException: WFNAM00003: Invalid naming provider URI: ldap://host.com:389 ldap://host2.com:389 [Root exception is java.net.URISyntaxException: Illegal character in authority at index 7: ldap://host.com:389 ldap://host2.com:389]
     	at org.wildfly.naming.client.ProviderEnvironment$Builder.populateProviderUris(ProviderEnvironment.java:540)
...
     Caused by: java.net.URISyntaxException: Illegal character in authority at index 7: ldap://host.com:389 ldap://host2.com:389
     	at java.net.URI$Parser.fail(URI.java:2848)

Also, check if this is happening with a specific user, check if there isn't any role for that user that contains a special character like :, ,, etc.

Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.