troubleshooting Question

EJB: ClassCastException narrowing an EJB home interface from a servlet.

Avatar of mister_snaggs
mister_snaggs asked on
JavaJava EE
7 Comments2 Solutions971 ViewsLast Modified:
This is driving me absolutely nuts!

I am deploying to Weblogic 7, each of the following -:

1. An EAR contain a JAR with a Session bean.
2. A WAR containing a servlet that accesses the aforementioned Session bean.

The session bean has a remote interface, which I have successfully called from a command-line test harness. However, when I try to call the same Session Bean from the WAR, a ClassCastException is raised with the mess "Cannot narrow remote object to <package.Class>".

The WAR file maintains a standard WAR file structure, with the bean JAR file in the /lib directory.

The web.xml is in the /WEB-INF directory, along with a weblogic.xml. The important bits of their contents are listed below -:

* web.xml-:

* weblogic.xml -:

The code to access the problem bean is pretty standard-:

ProblemBeanHome problemHome = (ProblemBeanHome) PortableRemoteObject.narrow("ejb/ProblemBeanHome", com.bugger.ProblemBeanHome.class);
ProblemBeanRemote problem = problemHome.create();


Has anyone else had a similar problem before. I have tried absolutely everything I can think of? I have tried including the ejb JAR in the WAR with the generated ejb classes and without. I have made absolutely certain that the EJB JAR file is exactly the same version as the one deployed in the EAR. I have even tried not narrowing the bloody home interface in the servlet. The last thing I haven't tried, and would rather not have to do, is to extract the classes from the JAR into the /classes directory of the WAR. I discovered that the class that is being returned to the servlet is one of the generated ejb classes, which implements the ProblemBeanHome interface!

I just don't understand what is going wrong!

Please, can somebody help me.

Thanks in advance.
(sorry, I don't have that many points to give at the moment...)
Join our community to see this answer!
Unlock 2 Answers and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros