2 Replies Latest reply on Jun 27, 2008 11:06 PM by superDev superDev

    Error when narrowing a session bean (remote interface) deplo

    superDev superDev Newbie

      Hello forum,

      I deployed a web application into JBoss 4.2.2 GA, and in this web application, a managed bean will have access to a EJB session bean (remote interface) deployed in the same JBoss server, but I got this error:

      ERROR [STDERR] java.lang.ClassCastException
      20:01:44,775 ERROR [STDERR] at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:229)
      20:01:44,775 ERROR [STDERR] at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)

      20:01:44,802 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
      20:01:44,802 ERROR [STDERR] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
      20:01:44,803 ERROR [STDERR] at java.lang.Thread.run(Thread.java:619)
      20:01:44,803 ERROR [STDERR] Caused by: java.lang.ClassCastException: $Proxy85 cannot be cast to org.omg.CORBA.Object
      20:01:44,804 ERROR [STDERR] at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:212)

      The code to get the session bean handler:

      Properties env = new Properties( );
      env.put(Context.SECURITY_PRINCIPAL, "guest");
      env.put(Context.SECURITY_CREDENTIALS, "guest");
      env.put(Context.PROVIDER_URL, "jnp://localhost:1099");

      Context jndi = new InitialContext(env);
      Object ref = jndi.lookup("MyBean/remote");
      instance = (MyBeanRemote) PortableRemoteObject.narrow(ref, MyBeanRemote.class);

      I can get "ref" from Context, just get error when narrow it. And with the same code deployed to tomcat, it works fine.

      I wonder whether anyone has met with this problem or can see some error in my code.

      Thanks a lot in advance!