0 Replies Latest reply on May 8, 2002 7:05 AM by chen

    NoInitialContextException in a client like "howto" example

    chen

      Hello,
      I test the JAAS example "howto" from Scott Stark. It works.
      Then I add the security component to my application.
      Like the "howto" example I modify the deployment descriptor files ejb-jar.xml and jboss.xml. Two new files users.properites and roles.properties are also added into the jar package. After successful deploying I try
      to access the Bean with a Client like the example. But a exception
      is thrown:

      ...
      [java] Created LoginContext
      [java] javax.naming.NoInitialContextException: Need to specify class name in
      environment or system property, or as an applet parameter, or in an application
      resource file: java.naming.factory.initial
      [java] at javax.naming.spi.NamingManager.getInitialContext(NamingManage
      r.java:643)
      ...

      Source of this client:
      ---------------------------------
      class SecureTestClient {
      static class AppCallbackHandler implements CallbackHandler
      { ...
      like "howto" example
      }

      public static void main {

      AppCallbackHandler handler = new AppCallbackHandler(name, password);
      LoginContext lc = new LoginContext("TestClient", handler);
      System.out.println("Created LoginContext");
      lc.login();


      InitialContext iniContext = new InitialContext();
      SessionHome home = (SessionHome) iniContext.lookup("project1/SessionBean1");
      Session bean = home.create();

      ...

      }
      }
      ---------------------------------
      The statement with "iniContext.lookup("project1/SessionBean1")" cause the exception.
      In jboss.xml I give this JNDI-Name "project1/SessionBean1" for a bean.
      And I can use this JNDI-Name before I made the changes.
      Then I call also my old test client without the LoginContext and try to call lookup
      of JNDI direktly and I can get the home reference! But I receive the security exception,
      when I want to create a remote object for this home reference.
      ...
      [java] java.rmi.ServerException: RemoteException occurred in server thread;
      nested exception is:
      [java] java.rmi.RemoteException: checkSecurityAssociation; nested excep
      tion is:
      [java] java.lang.SecurityException: Authentication exception, principal
      =null
      ...

      This exception is expected. My client hasn't used login context.

      Has somebody an idea, why does my Client
      similar "howto" example get NoInitialContextException?

      regards,
      chen