1 Reply Latest reply on Mar 27, 2003 9:24 AM by Lynn Pye

    JBoss 3.0.4/Novel LDAP/NotContextException

    Lynn Pye Newbie

      Hi all,

      I've looked around, checking the forums, Google, the docs, and haven't seen (or at least recognized) the solution to my problem, so I'm posting in hopes that someone will be able and willing to help.

      I'm moving an application from Weblogic to JBoss and have managed okay so far. I've gotten database connectivity, managed the build environment (which has a different layout than what we used with WL) and so on. What I'm hung on is our LDAP authentication.

      For our authentication, the user provides a username and a password on our login screen. We do a database lookup against their username in our database and grab their DN. We then check their DN and password against a Novell LDAP server for authentication, retrieving their grace logins attributes, assuming their password has expired. If it has, we report they logged in, but tell them the number of logins remaining and so on. We do all of this because we use Novell for our NT logins and this allows them to use the same password for their machine login and for the application login.

      The following is the pertinent code regarding our authentication procedure:

      Hashtable env = new Hashtable();
      DirContext ctx2 = null;
      try {
      ctx2 = new InitialDirContext(env);
      Attributes attrs1 = ctx2.getAttributes(userDn,
      new String[]{"loginGraceLimit","loginGraceRemaining"});
      } catch (Exception e) {

      Obviously userDn and userPwd are the DN and password of the user being authenticated. In WL, this works. In JBoss, I get the following stack trace:

      15:48:36,203 ERROR [STDERR] javax.naming.NotContextException: Not an instance of DirContext
      15:48:36,204 ERROR [STDERR] at javax.naming.directory.InitialDirContext.getURLOrDefaultInitDirCtx(InitialDirContext.java:90)
      15:48:36,205 ERROR [STDERR] at javax.naming.directory.InitialDirContext.getAttributes(InitialDirContext.java:121)
      15:48:36,205 ERROR [STDERR] at us.nc.state.ehnr.aq.controller.DaqServlet.authenticatePassword(DaqServlet.java:1133)
      15:48:36,205 ERROR [STDERR] at us.nc.state.ehnr.aq.controller.DaqServlet.handleUserReq(DaqServlet.java:492)
      15:48:36,206 ERROR [STDERR] at us.nc.state.ehnr.aq.controller.DaqServlet.doPost(DaqServlet.java:216)
      15:48:36,206 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
      15:48:36,206 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      15:48:36,211 ERROR [STDERR] at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:366)
      15:48:36,212 ERROR [STDERR] at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:293)
      15:48:36,212 ERROR [STDERR] at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:581)
      15:48:36,212 ERROR [STDERR] at org.mortbay.http.HttpContext.handle(HttpContext.java:1687)
      15:48:36,213 ERROR [STDERR] at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:544)
      15:48:36,213 ERROR [STDERR] at org.mortbay.http.HttpContext.handle(HttpContext.java:1637)
      15:48:36,214 ERROR [STDERR] at org.mortbay.http.HttpServer.service(HttpServer.java:875)
      15:48:36,214 ERROR [STDERR] at org.jboss.jetty.Jetty.service(Jetty.java:543)
      15:48:36,214 ERROR [STDERR] at org.mortbay.http.HttpConnection.service(HttpConnection.java:806)
      15:48:36,215 ERROR [STDERR] at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:956)
      15:48:36,215 ERROR [STDERR] at org.mortbay.http.HttpConnection.handle(HttpConnection.java:823)
      15:48:36,215 ERROR [STDERR] at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:203)
      15:48:36,216 ERROR [STDERR] at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:290)
      15:48:36,216 ERROR [STDERR] at org.mortbay.util.ThreadPool$JobRunner.run(ThreadPool.java:743)
      15:48:36,216 ERROR [STDERR] at java.lang.Thread.run(Thread.java:554)

      At this point, I'm left wondering what else I need to do to configure JBoss to make this work. Can it do this? It seems simple enough.

      Anyway, any help will be greatly appreciated.

      Btw, I posted a similar question yesterday, but in the forum transition, my post appears to have been lost, so I'm reposting.


      Lynn Pye