Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8186101

cannot access class com.sun.jndi.dns.DnsContextFactory from java.naming

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 9
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:

      Description

      FULL PRODUCT VERSION :
      java version "9"
      Java(TM) SE Runtime Environment (build 9+179)
      Java HotSpot(TM) Server VM (build 9+179, mixed mode, emulated-client, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 10.0.14393]

      A DESCRIPTION OF THE PROBLEM :
      The DNS JNDI initial context can't be created with Java 9.

      REGRESSION. Last worked in version 8u152

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I expect that I can use DNS without adding exports between any internal Java Modules.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.jndi.dns.DnsContextFactory [Root exception is java.lang.IllegalAccessException: class javax.naming.spi.NamingManager (in module java.naming) cannot access class com.sun.jndi.dns.DnsContextFactory (in module jdk.naming.dns) because module jdk.naming.dns does not export com.sun.jndi.dns to module java.naming]
          at java.naming/javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
          at java.naming/javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
          at java.naming/javax.naming.InitialContext.init(Unknown Source)
          at java.naming/javax.naming.InitialContext.<init>(Unknown Source)
          at java.naming/javax.naming.directory.InitialDirContext.<init>(Unknown Source)
          at ....
      Caused by: java.lang.IllegalAccessException: class javax.naming.spi.NamingManager (in module java.naming) cannot access class com.sun.jndi.dns.DnsContextFactory (in module jdk.naming.dns) because module jdk.naming.dns does not export com.sun.jndi.dns to module java.naming
          at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Unknown Source)
          at java.base/jdk.internal.reflect.Reflection.ensureMemberAccess(Unknown Source)
          at java.base/java.lang.Class.newInstance(Unknown Source)
          ... 62 more

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      Hashtable<String, String> env = new Hashtable();
      env.put( "java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory" );
      DirContext dns = new InitialDirContext( env );
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Add export command line parameters

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                psonal Pallavi Sonal
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: