[jboss-user] [Installation, Configuration & DEPLOYMENT] - Error when narrowing a session bean (remote interface) deplo

sunnyDev do-not-reply at jboss.com
Fri Jun 27 10:06:08 EDT 2008

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!

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4161183#4161183

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4161183

More information about the jboss-user mailing list