Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ClassCastException on narrow

Alan Peltz
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have a project that we deploy to Jboss 3.2.1/Tomcat 4.1.24. We will call it proj1.ear. We have another project (proj2.ear) that has a stateless session bean (SessBeanProj2). SessBeanProj2 would really like to reuse a stateless session bean in proj1 (UsefulSessBeanProj1 � actually sits in proj1EJB.jar which is eared up in proj1.ear). Here�s a code snippet:
InitialContext ctx = new InitialContext();
Object fromJNDI = ctx.lookup("ejb/UsefulSBProj1");
Object usefulSbHome = PortableRemoteObject.narrow(fromJNDI, IUsefulSBProj1Home.class);
This throws a ClassCastException. The stacktrace is below.
I have been researching this for a bit, so I have heard some things about Classloaders and some about the Classpath, but I need some more specifics. If it is the classpath issue, what do I need on the classpath? Do I need the ear on the classpath? Or just proj1EJB.jar? I am putting these things on the Class-Path line in my manifest file � is this the correct way?
As you can see, I�m grasping. Any help would be much appreciated. Thanks!
Here is part of the stacktrace. I will give you the whole thing if you think it will be useful, but I didn�t think it would be:
at javax.rmi.PortableRemoteObject.narrow(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic