3 Replies Latest reply on Sep 24, 2002 2:19 PM by Adrian Brock

    MBean + EJB =  Authentication exception, principal=null

    Oriol Newbie

      Hi,
      I'm trying to access an EJB from Mbeam. This is the code:

      private void login(String username,String password) throws javax.security.auth.login.LoginException {
      try {
      UsernamePasswordHandler handler = new UsernamePasswordHandler(username, password.toCharArray());
      LoginContext lc = new LoginContext("my-policy", handler);
      System.out.println("Created LoginContext");
      lc.login();
      System.out.println("Login completed");
      }
      catch (LoginException le) {
      System.out.println("Login failed");
      le.printStackTrace();
      throw new javax.security.auth.login.LoginException("Login failed");
      }
      }


      public void handleNotification(Notification n, Object handback) {
      try{
      System.out.println(n.getMessage());
      this.login("test","test");
      ProjectSessionLocalHome h=ProjectSessionUtil.getLocalHome();
      ProjectSessionLocal prj= h.create("myproject");
      System.out.println("Project Name:" +prj.getName());
      }catch(Exception ex){ex.printStackTrace();}

      }

      I always have the same error:
      -------------------------------------------------------
      09:21:10,715 ERROR [SecurityInterceptor] Authentication exception, principal=n
      l
      09:21:10,840 ERROR [LogInterceptor] EJBException, causedBy:
      java.lang.SecurityException: Authentication exception, principal=null
      at org.jboss.ejb.plugins.SecurityInterceptor.checkSecurityAssociation(
      curityInterceptor.java:173)
      at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterc
      tor.java:94)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.in
      keHome(CachedConnectionInterceptor.java:215)
      at org.jboss.ejb.plugins.StatefulSessionInstanceInterceptor.invokeHome
      tatefulSessionInstanceInterceptor.java:128)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxIn
      rceptor.java:111)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterc
      torCMT.java:178)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.
      va:52)
      at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java
      29)
      at org.jboss.ejb.StatefulSessionContainer.invokeHome(StatefulSessionCo
      ainer.java:368)
      at org.jboss.ejb.plugins.local.BaseLocalContainerInvoker.invokeHome(Ba
      LocalContainerInvoker.java:230)
      at org.jboss.ejb.plugins.local.LocalHomeProxy.invoke(LocalHomeProxy.ja
      :110)
      at $Proxy768.create(Unknown Source)
      at hero.util.TimerReceiver.handleNotification(TimerReceiver.java:74)
      at org.jboss.mx.server.NotificationListenerProxy.handleNotification(No
      ficationListenerProxy.java:71)
      at javax.management.NotificationBroadcasterSupport.sendNotification(No
      ficationBroadcasterSupport.java:84)
      at javax.management.timer.Timer.sendNotifications(Timer.java:441)
      at javax.management.timer.Timer.access$000(Timer.java:31)
      at javax.management.timer.Timer$RegisteredNotification.doRun(Timer.jav
      612)
      at org.jboss.mx.util.SchedulableRunnable.run(SchedulableRunnable.java:
      4)
      at org.jboss.mx.util.ThreadPool$Worker.run(ThreadPool.java:225)


      -------------------------------------------------

      Any solution?

      Thanks.