Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-9208

Incorrect class loader is used for loading custom Initial context factory in Elytron dir-context

XMLWordPrintable

    • Hide

      For reproduction you can use following dir-context:

      <dir-context name="dir-context-localhost" url="ldap://127.0.0.1:10389" principal="uid=admin,ou=system">
          <credential-reference clear-text="secret"/>
          <properties>
              <property name="java.naming.factory.initial" value="com.sun.jndi.ldap.LdapCtxFactory"/>
          </properties>
      </dir-context>
      
      Show
      For reproduction you can use following dir-context: <dir-context name= "dir-context-localhost" url= "ldap: //127.0.0.1:10389" principal= "uid=admin,ou=system" > <credential-reference clear-text= "secret" /> <properties> <property name= "java.naming.factory.initial" value= "com.sun.jndi.ldap.LdapCtxFactory" /> </properties> </dir-context>

      Quoting from [1]:

      DEBUG [org.wildfly.security] (default task-1) Could not create [class javax.naming.ldap.InitialLdapContext]. Failed to connect to LDAP server.: javax.naming.NamingException: WFLYNAM0027: Failed instantiate InitialContextFactory "com.sun.jndi.ldap.LdapCtxFactory" from classloader ModuleClassLoader for Module "deployment.print-roles.war" from Service Module Loader [Root exception is java.lang.ClassNotFoundException: "com.sun.jndi.ldap.LdapCtxFactory" from [Module "deployment.print-roles.war" from Service Module Loader]]
      at org.jboss.as.naming.InitialContext.getDefaultInitCtx(InitialContext.java:120)
      at org.jboss.as.naming.InitialContext.init(InitialContext.java:101)

      We can see from the stack trace the deployments class loader is being used.

      I think by default the ClassLoader of the subsystem should be used i.e. that will have the common dependencies. However we may want to also add a module attribute so an alternative module can be specified for when creating the InitialDirContext.

      [1] https://issues.jboss.org/browse/JBEAP-8025?focusedCommentId=13370291&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13370291

            rhn-cservice-bbaranow Bartosz Baranowski
            olukas Ondrej Lukas (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: