javax.naming.NotContextException: Not an instance of DirContext at javax.naming.directory.InitialDirContext. getURLOrDefaultInitDirCtx(InitialDirContext.java:92) at javax.naming.directory.InitialDirContext. search(InitialDirContext.java:210)

Oracle Community | 392 Guest | 8 years ago
  1. 0

    LDAP errors under GF_v3, works fine in v2

    Oracle Community | 8 years ago | 392 Guest
    javax.naming.NotContextException: Not an instance of DirContext at javax.naming.directory.InitialDirContext. getURLOrDefaultInitDirCtx(InitialDirContext.java:92) at javax.naming.directory.InitialDirContext. search(InitialDirContext.java:210)
  2. 0

    Application could not use DNS Service Provider for the Java Naming Directory Interface (http://download.oracle.com/javase/6/docs/technotes/guides/jndi/jndi-dns.html). The following exception is always thrown: javax.naming.NotContextException: Not an instance of DirContext at javax.naming.directory.InitialDirContext.getURLOrDefaultInitDirCtx(InitialDirContext.java:92) at javax.naming.directory.InitialDirContext.getAttributes(InitialDirContext.java:123) at javax.naming.directory.InitialDirContext.getAttributes(InitialDirContext.java:118) at example.DnsServiceServlet.doGet(DnsServiceServlet.java:28) at javax.servlet.http.HttpServlet.service(HttpServlet.java:734) at example.DnsServiceServlet.service(DnsServiceServlet.java:50001) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) at example.DnsServiceServlet.service(DnsServiceServlet.java:50001) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97) at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165) at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791) at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693) at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954) at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170) at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88) at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76) at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53) at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57) at com.sun.grizzly.ContextTask.run(ContextTask.java:69) at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330) at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309) at java.lang.Thread.run(Thread.java:619) You can easily reproduce an error with the following code snippet: @WebServlet("/DnsServiceServlet") public class DnsServiceServlet extends HttpServlet { private static final long serialVersionUID = 1L; protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); try { DirContext context = new InitialDirContext(); String attributeName = "dns:///www.google.com"; Attributes attributes = context.getAttributes(attributeName); NamingEnumeration<? extends Attribute> results = attributes.getAll(); while (results.hasMore()) { Attribute result = results.next(); out.println(result.toString()); } } catch (NamingException e) { throw new ServletException(e); } } } As an outcome I expect something like "CNAME: www.l.google.com.". I'm not sure that it is a Glassfish bug or invalid JNDI API usage under application server environment. I also found similar issues in the other bug trackers, both of them are related to the Glassfish: http://rubyforge.org/tracker/?func=detail&atid=7857&aid=27115&group_id=2014 http://issues.liferay.com/browse/LEP-6197 Any help will be really appreciated.

    Java.net JIRA | 6 years ago | mkuthan
    javax.naming.NotContextException: Not an instance of DirContext at javax.naming.directory.InitialDirContext.getURLOrDefaultInitDirCtx(InitialDirContext.java:92) at javax.naming.directory.InitialDirContext.getAttributes(InitialDirContext.java:123) at javax.naming.directory.InitialDirContext.getAttributes(InitialDirContext.java:118)
  3. 0

    [GLASSFISH-13685] javax.naming.NotContextException: Not an instance of DirContext - Java.net JIRA

    java.net | 11 months ago
    javax.naming.NotContextException: Not an instance of DirContext at javax.naming.directory.InitialDirContext.getURLOrDefaultInitDirCtx(InitialDirContext.java:92) at javax.naming.directory.InitialDirContext.getAttributes(InitialDirContext.java:123) at javax.naming.directory.InitialDirContext.getAttributes(InitialDirContext.java:118)
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    java server report error but can run in java app

    Oracle Community | 8 years ago | 843793
    javax.naming.NotContextException: Not an instance of DirContext
  6. 0

    DirContext.search(): NotContextException

    objectmix.com | 1 year ago
    javax.naming.NotContextException: Not an instance of DirContext

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. javax.naming.NotContextException

      Not an instance of DirContext at javax.naming.directory.InitialDirContext. getURLOrDefaultInitDirCtx(InitialDirContext.java:92) at javax.naming.directory.InitialDirContext. search(InitialDirContext.java:210)

      at ConnectLdap.search()
    2. Unknown
      ConnectLdap.search
      1. ConnectLdap.search(ConnectLdap.java:173)
      1 frame