3 Replies Latest reply on Oct 7, 2005 2:16 AM by Martin Heinemann

    Exception accessing Session Bean via JNDI

    Guilherme Melo e Maranhão Newbie

      Hi,

      I am accessing a Session Bean in this way:

      InitialContext context = new InitialContext();
      String lookup = FacadeRemote.class.getName();
      FacadeRemote facade = (FacadeRemote) context.lookup(lookup);

      But I receive this exception:

      java.lang.ClassCastException: org.jboss.ejb3.stateless.StatelessContainer
      org.jboss.ejb3.LocalProxy.readObject(LocalProxy.java:50)
      sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      java.lang.reflect.Method.invoke(Method.java:585)
      java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:919)
      java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1813)
      java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)
      java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
      java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1912)
      java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1836)
      java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)
      java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
      java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
      java.rmi.MarshalledObject.get(MarshalledObject.java:135)
      org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:57)
      org.jnp.interfaces.NamingContext.lookup(NamingContext.java:637)
      org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
      javax.naming.InitialContext.lookup(InitialContext.java:351)
      sistemaBancario.cliente.struts.logar.LogarAction.autenticarUsuario(LogarAction.java:63)
      sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      java.lang.reflect.Method.invoke(Method.java:585)
      org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:276)
      org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:196)
      org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
      org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
      org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
      org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81

      Does anybody know waht is wrong? Is there another way to access a Session Bean?

      Thanks, Guilherme