3 Replies Latest reply on Jan 4, 2008 6:47 AM by fla83tn

    Unable to call Stateful Session bean

    fla83tn

      Hi to all,
      I've lost all the day trying to figure out why I'm not able to use a Stateful bean: I'm really disperated!
      In my project I am able to call everything, except this Stateful bean! I've Stateless session, resources and so on!

      I lookup correctly to the object, but I cannot cat it to the interface class. The Exception throwed is an IllegalCastException: $Proxy195 (althought the Proxy number change at each deployment).

      It seems that the looked up object is not an instance of the interface!, althought the JNDI deploy it correctly! (see below)

      This is the output of the JNDI view:



      +- NewsCrawler (class: org.jnp.interfaces.NamingContext)
      | +- UserSessionFacadeBean (class: org.jnp.interfaces.NamingContext)
      | | +- local (proxy: $Proxy97 implements interface nc.session.facade.user.UserSessionFacadeLocal,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBLocalObject)
      | | +- remote (proxy: $Proxy96 implements interface nc.session.facade.user.UserSessionFacade,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBObject)
      | +- UserStatefulBean (class: org.jnp.interfaces.NamingContext)
      | | +- remote (class: java.lang.Object)
      | | +- remoteStatefulProxyFactory (proxy: $Proxy68 implements interface org.jboss.ejb3.ProxyFactory)

      | +- AdminSessionFacadeBean (class: org.jnp.interfaces.NamingContext)
      | | +- remote (proxy: $Proxy93 implements interface nc.session.facade.admin.AdminSessionFacade,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBObject)


      and this is the simple Stateful bean I want to call:
      package nc.session.stateful;
      
      import nc.gwt.client.dtos.*;
      import javax.ejb.Remote;
      
      @Remote
      public interface UserStateful{
       public boolean login();
       public boolean logout();
       public UserStateDTO isLogged();
       public void setUserDTO(UserDTO u);
       public void addHistoryToken(String token);
      }
      
      
      
      
      package nc.session.stateful;
      
      import java.util.List;
      import javax.ejb.Stateful;
      import nc.gwt.client.dtos.*;
      
      @Stateful
      public class UserStatefulBean implements UserStateful{
      
       private UserStateDTO status=new UserStateDTO(false);
      
       public boolean login(){
       status.setLogged(true);
       return true;
       }
       public boolean logout(){
       status.setLogged(false);
       return false;
       }
       public UserStateDTO isLogged(){
       return status;
       }
      
       public void setUserDTO(UserDTO u){
       status.setUserDTO(u);
       }
       public void addHistoryToken(String token){
       List<String> l=status.getHistory();
       l.add(token);
       status.setHistory(l);
       }
      
      }
      


      Any Ideas?
      Thanks in advanced, Flavio


        • 1. Re: Unable to call Stateful Session bean
          waynebaylor

          are you doing something like:

          UserStateful bean = (UserStateful)new InitialContext().lookup("UserStatefulBean/remote");
          


          • 2. Re: Unable to call Stateful Session bean
            fla83tn

            Yes..I do the following:

             try {
             InitialContext ctx=new InitialContext();
             stateful=(UserStateful)ctx.lookup("NewsCrawler/UserStatefulBean/remote");
             } catch (ServiceLocatorException e) {
             e.printStackTrace();
             }
            


            The object is looked up correctly, but it is not an instance of UserStateful. It is an instance of Proxy.
            From what you can see from the JndiView it says it is an instance of object...is it correct that it is an instance of Object? Shouldn't the JndiView tell me that is an Instance of Proxy?

            • 3. Re: Unable to call Stateful Session bean
              fla83tn

              I just change server to jboss-4.2.2.GA and now everything is fine..! All 1 day throwed away for nothing!! :(


              UserStatefulBean (class: org.jnp.interfaces.NamingContext)
              | | +- remote (proxy: $Proxy121 implements interface nc.session.stateful.UserStateful,interface org.jboss.ejb3.JBossProxy)