1 Reply Latest reply on Jul 15, 2005 12:09 AM by Anton Popov

    Troubles when mbean invokes method of a secured local ejb

    Anton Popov Newbie

      Hi All,

      I have one MBean and one local secured EJB.
      Both of them are working in same security domain.

      I want to invoke a method of this local EJB from my MBean.

      I do the following:

      1. From my MBean I log on in my security domain as usual, by using "UsernamePasswordHandler" or custom "AppCallbackHandler".
      Login is successfull.
      (I tried without login, but the end result was also unsuccessfull).

      2. I create local home:
      ReceiptLocalHome receiptnHome = (ReceiptLocalHome)initContext.lookup("ReceiptBeanLocal");

      This is also successfull.

      3. I create the bean:
      receipt = receiptnHome.create();

      This line fails with:
      "javax.security.auth.login.FailedLoginException: No matching username found in Principals".

      In my "ejb-jar.xml" I have roles, method permissions, etc.

      In my "login-config.xml" I have the following security domain:

      <application-policy name = "ReceiptSecurityDomain">
       <login-module code =
      "org.jboss.security.auth.spi.DatabaseServerLoginModule" flag ="required">
      <module-option name =
      <module-option name ="dsJndiName">java:/ReceiptDS</module-option>
      <module-option name = "principalsQuery">SELECT password FROM Principals WHERE username=?</module-option>
      <module-option name = "rolesQuery">SELECT roles, 'Roles' FROM PrincipalRoles WHERE username=?</module-option>

      I have read "FAQJBossJMX" and there was a question:
      "How can an EJB call an MBean?".
      This is good, but unfortunately there is no answer of the opposite question: "How to invoke (secured local) ejb from an MBean?".

      Can someone help me where could be the problem?