2 Replies Latest reply on Mar 23, 2007 3:44 PM by ericchile

    Can't access session facade bean

    ericchile

      I don't understand why I am getting a classcastexception...

      From the rmx console

       +- SDS_DATA (class: org.jnp.interfaces.NamingContext)
       | +- SessionEJB (class: org.jnp.interfaces.NamingContext)
       | | +- local (proxy: $Proxy97 implements interface org.usiis.model.SessionEJBLocal,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBLocalObject)
       | | +- remote (proxy: $Proxy96 implements interface org.usiis.model.SessionEJB,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBObject)
      


      My java code

      import javax.naming.Context;
      import javax.naming.InitialContext;
      
      import org.usiis.model.SessionEJB;
      import org.usiis.model.SessionEJBLocal;
      
      public class ContextManager {
      
       private final String oc4jRemote = "SessionEJB";
       private final String bossRemote = "SDS_DATA/SessionEJB/remote";
       private final String bossLocal = "SDS_DATA/SessionEJB/local";
      
       public ContextManager() {
       }
      
      
       public SessionEJB getRemoteContext ()throws Exception {
       final Context context = new InitialContext();
       //SessionEJB b = (SessionEJB) context.lookup(oc4jRemote);
       SessionEJB b = (SessionEJB) context.lookup(bossRemote);
      
       return b;
       }
      
      
       public SessionEJBLocal getLocalContext() throws Exception {
       final Context context = new InitialContext();
       SessionEJBLocal b = (SessionEJBLocal) context.lookup(bossLocal);
      
       return b;
       }
      


      The error

      
      2:35:36,674 ERROR [STDERR] java.lang.ClassCastException: $Proxy97
      2:35:36,674 ERROR [STDERR] at org.usiis.view.backing.ContextManager.getLoca
      Context(ContextManager.java:30)
      
      



      Can anyone explain why the cast is not working?

        • 1. Re: Can't access session facade bean
          ericchile

          Also I did make sure that the jar file that contains my SessionEJBBean, SessionEJB, SessionEJBLocal is not in the WEB-INF/lib directory of my webapp.war (it was at one time) so as not to have problems with the classloader. It is only in the ear file.

          But I am still having the same problem.

          I am casting the interface and not the implementing class which I believe is the right thing to do. Can't get past this. Can anyone help?

          • 2. Re: Can't access session facade bean
            ericchile

            Problem solved. Even though it wasn't in the jar... it was in
            WEB-INF/classes

            Took it out of there and problem solved.