1 Reply Latest reply on Apr 17, 2008 10:17 AM by Martin Maier

    Class Loading Problem of LoginModule from MBean/SAR File

    Martin Maier Newbie

      Hi guys,

      I have a problem that has kept frustrating me over some time now. I have the following situation:
      I deploy a .sar file to my JBoss AS (4.0.5GA) containing an MBean that makes use of JBoss JAAS Security by calling

      LoginContext lc = new LoginContext("myJaas");

      The JAAS application policy is configured in my conf/login-config.xml like this:
       <application-policy name="myJaas">
       <login-module code="mypackage.MyLoginModule" flag="required" />

      Other than that, I have nothing changed in the default configuration of my JBoss. I am using the 'default' instance.

      When the MBean calls the snippet above I receive the following error:
      javax.security.auth.login.LoginException: unable to find LoginModule class: myPackage.MyLoginModule
       at javax.security.auth.login.LoginContext.invoke(LoginContext.java:808)
       at javax.security.auth.login.LoginContext.access$000(LoginContext.java:186)
       at javax.security.auth.login.LoginContext$4.run(LoginContext.java:683)
       at java.security.AccessController.doPrivileged(Native Method)
       at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680)
       at javax.security.auth.login.LoginContext.login(LoginContext.java:579)

      I am pretty sure it is a class loading problem because I CAN load the class fine the when I put the jar containing myPackage.MyLoginModule an the classpath using JBOSS_CLASSPATH system variable.
      Every other attempt to put this jar in the lib-dir of JBoss or the default instance has failed. Likewise, the same error occurs when I package the jar along with my sar-File.

      What am I missing? Is it even possible to use the JBoss JAAS config from an MBean? Do you have any other ideas how I can use JAAS from an MBean?

      Thank you

        • 1. Re: Class Loading Problem of LoginModule from MBean/SAR File
          Martin Maier Newbie

          Okay, I solve it.

          The problem was that I programmatically added another MBean from the MBean contained and registered along with the SAR-File I used the following code:

          MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
          MyNewMBeanObject status = new MyNewMBeanObject();
          mbs.registerMBean(status, oName);

          So far so good, the added MBean can access all classes but no LoginModules (via LoginContext). Apparently JBoss does not like it, when you add an MBean programmtically and access JAAS from it. MBeans registered by JBoss via SAR-Files can access LoginModules just fine.