3 Replies Latest reply on Oct 29, 2006 10:44 AM by John Gilbert

    javax.ejb.EJBAccessException: Authentication failure

    pipo Newbie

      Hi,
      I have a simple Stateless Session Bean and a standalone client to invoke the Session Bean.

      The code:

      ...

      @Stateless
      @SecurityDomain("xifra")
      public class RolService implements IRolServiceLocal, IRolServiceRemote {
      @PersistenceContext(unitName = "xifra")
      private EntityManager em;

      public Rol merge(Rol rol) throws Exception {
      return em.merge(rol);
      }
      ...


      Client code:

      ...
      Properties properties = new Properties();
      properties.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
      properties.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
      properties.put("java.naming.provider.url", "jnp://localhost:1099");
      properties.put("jnp.disableDiscovery", "true");
      properties.put(InitialContext.SECURITY_PRINCIPAL, "system");
      properties.put(InitialContext.SECURITY_CREDENTIALS, "system");
      InitialContext initialContext = new InitialContext(properties);
      IRolServiceRemote iRolServiceRemote = (IRolServiceRemote) initialContext().lookup("xifra/RolService/remote");
      Rol rol = new Rol("ADMIN");
      rol = iRolServiceRemote.merge(rol);
      ...

      When I invoque the merge call to stateless session bean i get a javax.ejb.EJBAccessException: Authentication failure.

      My login-config.xml look like:

      ...
      <application-policy name="xifra">

      <login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule" flag="required">
      <module-option name="dsJndiName">java:/jdbc/xifra</module-option>
      <module-option name="principalsQuery">select passwd from usuario where usernme = ?</module-option>
      <module-option name="rolesQuery">select codigo, 'Roles' from rol left join usuario_rol on rol.id = usuario_rol.rol_id left join usuario on usuario_rol.usuario_id = usuario.id where usuario.usernme = ?</module-option>
      <module-option name="debug">true</module-option>
      </login-module>

      </application-policy>
      ...

      I got messages explaining that principal is null so I extended DatabaseServerLoginModule to see what username and password uses to authenticate and it's true, username and password are null.

      Can someone help me?

      Very thank you.V