3 Replies Latest reply on Feb 17, 2003 2:45 AM by Dirk Meister

    Login from Schedulable

    Dirk Meister Newbie

      I want to call some EJB-Methods from inside an Schedulable started inside a MBean.

      The Authentication with jaas didnot failed, altough i
      always i got Authentication exceptions when i calls the ejb-method.
      Can anyone help?

      This is the exception trace:
      java.lang.SecurityException: Authentication exception, principal=null
      at org.jboss.ejb.plugins.SecurityInterceptor.checkSecurityAssociation(SecurityInterceptor.java:173)
      at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:94)
      at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:129)
      at org.jboss.ejb.StatelessSessionContainer.invokeHome(StatelessSessionContainer.java:300)
      at org.jboss.ejb.Container.invoke(Container.java:730)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
      at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:98)
      at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:102)
      at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:77)
      at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:80)
      at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:198)
      at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:76)
      at $Proxy55.create(Unknown Source)
      at [package cut].TimeTrigger.perform(TimeTrigger.java:68)
      at org.jboss.varia.scheduler.Scheduler$Listener.handleNotification(Scheduler.java:1046)
      at org.jboss.mx.server.NotificationListenerProxy.handleNotification(NotificationListenerProxy.java:71)
      at javax.management.NotificationBroadcasterSupport.sendNotification(NotificationBroadcasterSupport.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.java:612)
      at org.jboss.mx.util.SchedulableRunnable.run(SchedulableRunnable.java:164)
      at org.jboss.mx.util.ThreadPool$Worker.run(ThreadPool.java:225)

      This is the Schedulable-code:
      [import statements cut]

      public class TimeTrigger implements Schedulable {
      private static Logger log = Logger.getLogger(TimeTrigger.class);

      String username;
      String password;

      public TimeTrigger(String user,String password) {
      super();
      try {
      this.login(user,password);
      } catch (LoginException e) {
      log.error("Cannot log in");
      }
      }
      public void perform(Date date, long repetitions) {
      SchedularHome home;
      try {
      home = SchedularUtil.getHome();
      Schedular schedular = home.create();
      schedular.startDueItems();

      } catch (NamingException e) {
      log.error("Naming Exception", e);
      } catch (CreateException e) {
      log.error("Creation Exception", e);
      } catch (RemoteException e) {
      log.error("Remote Exception", e);
      }
      }

      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("client-login", handler);
      log.debug("Created LoginContext");
      lc.login();

      log.debug("Login completed");
      } catch (LoginException le) {
      log.error("Login failed");
      throw new javax.security.auth.login.LoginException("Login failed");
      }
      }
      }

      Why is the principal null?