0 Replies Latest reply on Sep 26, 2013 5:27 AM by gunterze

    java.lang.ClassNotFoundException: com.sun.jndi.ldap.LdapCtxFactory

    gunterze

      Accessing a LDAP server by


      new InitialDirContext(env)

       

      from an OSGI bundle throws


      java.lang.ClassNotFoundException: com.sun.jndi.ldap.LdapCtxFactory

      detailMessage: com.sun.jndi.ldap.LdapCtxFactory from [Module "org.jboss.osgi.framework:main" from local module loader @75bb613c (finder: local module finder @60ece686 (roots: /home/gunter/wildfly-8.0.0.Alpha4/modules,/home/gunter/wildfly-8.0.0.Alpha4/modules/system/layers/base))]

       

      from


      org.jboss.as.naming.InitialContextFactoryBuilder#createInitialContextFactory()

       

      and you have to kill -9 the vm process (cli :shutdown or Ctrl+C hangs).

       

      We tried to invoke the VM with

      -Dorg.osgi.framework.system.packages.extra=com.sun.jndi.ldap

      as suggested by http://spring.io/blog/2009/01/19/exposing-the-boot-classpath-in-osgi/ , but it did not work.

       

      We had to use

      -Djboss.modules.system.pkgs=com.sun.jndi.ldap

      (setting the system property by

      cli: /system-property=jboss.modules.system.pkgs:add(value=com.sun.jndi.ldap

      did not work).

       

      Another solution we found is to add

      <module name="sun.jdk"/>

      to

      wildfly-8.0.0.Alpha4/modules/system/layers/base/org/jboss/as/osgi/main/module.xml

      - needed if invoking new InitialDirContext(env) by BundleActivator.start() - and to

      wildfly-8.0.0.Alpha4/modules/system/layers/base/org/jboss/osgi/framework/main/module.xml

      - needed if invoking new InitialDirContext(env) by the init method of a Blueprint service.

       

      Is there a better solution?

       

      gunter