4 Replies Latest reply on Aug 28, 2002 6:38 AM by swatkat

    jndiView MBean doesnt work with ExternalContext

    swatkat

      OLD EXTERNAL LDAP CONFIG for JBOSS Version 2.4.4

      --------------
      jboss.jcml
      --------------

      <!-- Bind a remote LDAP server -->

      external/ldap/practiceit
      sscldap.conf
      javax.naming.ldap.InitialLdapContext
      true


      OLD EXTERNAL LDAP CONFIG for JBOSS Version 2.4.4
      --------------
      sscldap.conf
      --------------
      java.naming.factory.initial=com.sun.jndi.ldap.LdapCtxFactory
      java.naming.provider.url=ldap://206.135.232.178:389/dc=practiceit,dc=net
      java.naming.security.principal=cn=SystemManager,dc=practiceit,dc=net
      java.naming.security.authentication=simple
      java.naming.security.credentials=secretpass


      ****************************************************
      WORKING JAVA CODE FOR JNDI ACCESS for Version 2.4.4
      ****************************************************

      public String search(String name)
      {
      String bId ="";
      try
      {
      /* Create an environment for the initial directory context.*/
      /* Create the initial directory context. */
      DirContext drctx = new InitialDirContext(getInitialLdapContext().getEnvironment());;
      /* Set up and perform the search. Find all matching in ou=name. */
      String base = "o=PracticeVeterinary";
      String filter = "(ou="+name+")";
      SearchControls constraints = new SearchControls();
      constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
      NamingEnumeration results = drctx.search(base,filter,constraints);
      /* Print the search results. */
      if (!results.hasMore())
      {
      System.out.println("Nothing found.");
      }
      else
      {
      while (results.hasMore())
      {
      SearchResult sr = (SearchResult) results.next();
      Attributes attrs = sr.getAttributes();
      if (attrs == null)
      {
      System.out.println("No attributes");
      }
      else
      {
      /* For each attribute of the entry.
      find a custom entry called bid */
      Attribute bIdCtx = attrs.get("bid");
      bId = (String)bIdCtx.get(0);
      }
      }
      }
      }
      catch (NamingException e)
      {
      /* Handle any name/directory exceptions. */
      }//catch
      catch (Exception e)
      {
      /* Handle any other types of exceptions. */
      }//catch
      return bId;
      }
      public Context getInitialLdapContext() throws NamingException
      {
      String ldapCtxString = "external/ldap/practiceit";
      InitialContext initCtx = new InitialContext();
      Context ldapCtx = (Context)initCtx.lookup(ldapCtxString);
      return ldapCtx;
      }


      JBOSS 3.0.1 SETTINGS

      ------------------
      jboss-service.xml
      ------------------

      <!-- Added for creating external JNDI Reference to LDAP server -->

      external/ldap/practiceit
      /conf/sscldap.conf
      javax.naming.ldap.InitialLdapContext
      true


      ---------------------------------
      sscldap.conf file in conf folder
      ---------------------------------

      java.naming.factory.initial=com.sun.jndi.ldap.LdapCtxFactory
      java.naming.provider.url=ldap://192.9.200.5:389/dc=practiceit,dc=net
      java.naming.security.principal=cn=SystemManager,dc=practiceit,dc=net
      java.naming.security.authentication=simple
      java.naming.security.credential=secretpass

      Once i add this reference and start the server the jndiView MBean doesnt work
      [B]
      If i invoke the list() function with (false) it just hangs and after around 20 minutes it
      gives out of memory error ( have put 512 M stack)[/B]

      [U]The list function works fine if i remove the externalContext configuration[/U]

      The java code too gives an exception "Not a DirContext" upon execution

        • 1. Re: jndiView MBean doesnt work with ExternalContext
          kratzda

          I am having the same error with the JNDIView.list method using an ExternalContext in JBoss 3.0. Any ideas?

          • 2. Re: jndiView MBean doesnt work with ExternalContext

            I don't know very much about ldap,
            but I know somebody else reported the same
            problem with the 2.4.x series on Redhat Linux.

            Strange thing was it worked fine on windows,
            maybe it is a JVM bug?

            If you think you have found a bug in jboss, report it at
            www.sf.net/projects/jboss

            Regards,
            Adrian

            • 3. Re: jndiView MBean doesnt work with ExternalContext
              swatkat

              It doesnt work on windows either

              I am running jboss 3.0.1
              on Windows 2000 Server ( Service Pack 2)

              java version "1.3.1_03"
              Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_03-b03)
              Java HotSpot(TM) Client VM (build 1.3.1_03-b03, mixed mode)

              The LDAP server is OpenLdap 2.19 from openldap.org

              The jndiView-->list() function just doesnt return and the server crashes with Out Of Memory Error

              Regards,
              Binoy

              • 4. Re: jndiView MBean doesnt work with ExternalContext
                swatkat

                It Doesnt work with Windows 2000 Server Either,
                I am using Windows 2000 Server, Service Pack 2

                JBoss Version 3.0.1 (CVS Build)

                Java : version "1.3.1_03"
                Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_03-b03)
                Java HotSpot(TM) Client VM (build 1.3.1_03-b03, mixed mode)

                but the problem is still there.. cant do a jndiview list method and cant access the external context resource too

                Regards

                Binoy