4 Replies Latest reply on Apr 26, 2008 4:10 PM by graben

    SeamLoginModule - Javassist EJB Stateless Stub does not implement the Local interface

    raresp

      Hello everyone,


      I've lost a day and a night trying to get to the bottom of this one. Please help if you can.


      Using JBoss 4.2.2.GA, Seam 2.0.1.GA


      I am trying to configure seam authenticator as a Stateless EJB but I am getting the following exception:


      23:34:03,557 ERROR [SeamLoginModule] Error invoking login method
      java.lang.IllegalArgumentException: value of context variable is not an instance of the component bound to the context variable: authenticator
           at org.jboss.seam.Component.getInstance(Component.java:1885)
           at org.jboss.seam.Component.getInstance(Component.java:1840)
           at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:55)
           at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:50)
           at org.jboss.seam.el.SeamELResolver.resolveBase(SeamELResolver.java:166)
           at org.jboss.seam.el.SeamELResolver.getValue(SeamELResolver.java:53)
           at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
           at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
           at org.jboss.el.parser.AstIdentifier.getValue(AstIdentifier.java:44)
           at org.jboss.el.parser.AstValue.getTarget(AstValue.java:34)
           at org.jboss.el.parser.AstValue.invoke(AstValue.java:95)
           at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
           at org.jboss.seam.core.Expressions$2.invoke(Expressions.java:173)
           at org.jboss.seam.security.jaas.SeamLoginModule.login(SeamLoginModule.java:109)
           at sun.reflect.GeneratedMethodAccessor335.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:585)
           at javax.security.auth.login.LoginContext.invoke(LoginContext.java:769)
      .....



      All my configurations are correct (at least I think they are) therefore I traced the exception in Seam source code and I found out that Component.isInstance() method is actually throwing the exception IllegalArgumentException correctly because the Javassist produced stub for the EJB does not implement the local interface.
      Don't know the reason for that, perhaps a BUG?


      Here are my settings:


      components.xml
      ...

      <core:init jndi-pattern="security-ear/#{ejbName}/local"/>
          
         <core:manager concurrent-request-timeout="500"
                       conversation-timeout="120000"
                       conversation-id-parameter="cid"/>

         <security:identity authenticate-method="#{authenticator.authenticate}" remember-me="true"/>
        
         <event type="org.jboss.seam.security.notLoggedIn">
             <action execute="#{redirect.captureCurrentView}"/>
         </event>
         <event type="org.jboss.seam.security.loginSuccessful">
             <action execute="#{redirect.returnToCapturedView}"/>
         </event>
        
         <mail:mail-session host="localhost" port="2525" username="test" password="test" />
           
      </components>


      The AuthenticatorAction and Authenticator are 100% as in the examples.


      Again, please help if you have a clue.


      Thank you,


      Rares

        • 1. Re: SeamLoginModule - Javassist EJB Stateless Stub does not implement the Local interface
          clatimer

          Can you post the code for your SLSB authenticator?


          hint: use backticks to format a block of code, it will retain your spacing and make things like component xml easier to read...

          • 2. Re: SeamLoginModule - Javassist EJB Stateless Stub does not implement the Local interface
            raresp

            Thank you for the quick response. Here it is :


            Authenticator.java


            import javax.ejb.Local;
            
            @Local
            public interface Authenticator{
                 
                 public boolean authenticate(); 
            }
            



            and AuthenticatorAction.java



            ...
            @Name("authenticator")
            @Stateless
            public class AuthenticatorAction implements Authenticator{
            
            
                 @Logger
                 Log log;
                 
                 @In
                 FacesMessages facesMessages;
                 
                 @In
                 Context sessionContext;
                 
                 @In
                 @Out(scope=ScopeType.SESSION)
                 Identity identity;
            
                 @EJB
                 private AgentLocal agentLocal;
                 
                 public boolean authenticate() {
                      log.info("authenticating #0", identity.getUsername());
                      
                      //HttpSession session =(HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true);
                      Agent agent = null;
                      
                      try {
                           
                           agent = agentLocal.getAgent(identity.getUsername());
                           
                      } catch (SecurityException e) {
                           e.printStackTrace();
                      }
                      if(agent.getPasswordHash().equals(identity.getPassword())){
                           //session.setAttribute("loggedInAgent",agent);
                           //sessionContext.set("loggedInAgent",agent);
                           //Contexts.getSessionContext().set("loggedInAgent",agent);
                           
                           //List<PermissionGrant> grantsForAgent = securityManagerRemote.getAgentPermissions(agent, null);
                           //Contexts.getSessionContext().set("grantsForAgent",grantsForAgent);
                           return true;
                      }
                      else {
                           return false;
                      }
                      
                      
                 } 
            }


            • 3. Re: SeamLoginModule - Javassist EJB Stateless Stub does not implement the Local interface
              raresp

              I have managed to pass by the initial problem, as it turned out, the jar containing the EJB-s was in two places, both the EAR and inside the WAR/LIB.


              However now I am facing another curious problem.
              All the members of the AuthenticatorAction are null, even log is not injected when authenticate is called.


              Any thoughts?

              • 4. Re: SeamLoginModule - Javassist EJB Stateless Stub does not implement the Local interface
                graben

                I don't know if that solves your problem but



                1. You don't have to outject identity since it is session scoped and binded to identity by default.

                2. Use @EJB only if you are sure EJB is not a Seam component. Otherwise use Component.getInstance(...) to make Seam knowing an instance has been created.

                3. Maybe try to make them private. Sometimes Java makes strange things.



                Hope I can help!