4 Replies Latest reply on Apr 18, 2004 6:39 PM by Steve Lewis

    Servlet using a Jboss Session - Bean

    josefduschinger Newbie


      i am using jboss3.2.3 with tomcat. I wrote a servlet, in which I want to use a JBoss - Session Bean.

      I always get the Excption like:

      EJBException:; nested exception is: javax.ejb.EJBException: checkSecurityAssociation; CausedByException is: Authentication exception, principal=null

      The source code is:

      public String execute(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.apache.velocity.context.Context pvContext)


      SecurityAssociationHandler handler = new SecurityAssociationHandler();
      Principal userPrincipal = new Principal()
      public String getName()
      return "georg";

      handler.setSecurityInfo(userPrincipal, "georg1");
      LoginContext loginContext =
      new LoginContext("EJBSecurityDomain", (CallbackHandler) handler);

      Context jndiContext = getInitialContext();

      Object ref = jndiContext.lookup("GeorgSQLHomeRemote");
      GeorgSQLHomeRemote georgHome = (GeorgSQLHomeRemote)

      GeorgSQLRemote georg = georgHome.create();

      pvContext.put ("Meldung", "Huhu");

      catch (Throwable t)
      pvContext.put ("Meldung", t.getMessage());

      return "userList.html";

      static public Context getInitialContext() throws Exception
      // jndi.properties contains InitialContext properties
      Hashtable env = new Hashtable();
      env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      env.put(Context.OBJECT_FACTORIES, "org.jboss.naming:org.jnp.interfaces");
      env.put(Context.PROVIDER_URL, "");

      return new InitialContext(env);

      My question, what have I to do, that the connection works?