Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes EJB and other Java EE Technologies and the fly likes EJB with Weblogic 5.1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB with Weblogic 5.1" Watch "EJB with Weblogic 5.1" New topic

EJB with Weblogic 5.1

cris abanades

Joined: Aug 30, 2001
Posts: 10
When I call a EJB in a servlet, it doesn't work but if I do this in an application client that calls EJB, it works perfectly.
What is the problem?
The exception is:
java.lang.ClassCastException at
at javax.rmi.PortableRemoteObject.narrow(
at src.servlet.gesServlet.init(
at src.servlet.mainServlet.init(
at weblogic.servlet.internal.ServletStubImpl.createServlet(
at weblogic.servlet.internal.ServletStubImpl.createInstances(
at weblogic.servlet.internal.ServletStubImpl.prepareServlet(
at weblogic.servlet.internal.ServletStubImpl.getServlet(
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(
at weblogic.servlet.internal.ServletContextImpl.invokeServlet(
at weblogic.servlet.internal.ServletContextImpl.invokeServlet(
at weblogic.servlet.internal.ServletContextManager.invokeServlet(
at weblogic.socket.MuxableSocketHTTP.invokeServlet(
at weblogic.socket.MuxableSocketHTTP.execute(
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

I had a LOT of fun with this one about a year back. There are several DIFFERENT CLASSPATHS within WLS5.1 - the first thing you need to do is make sure that the EJB is accessible through the right one. I believe there's a warning in the docs in particular about not putting stuff in the servlet classpath if it should be somewhere else. Or maybe it's in the comments in the model config file?
Anyway, what will happen is essentially, there are two copies of the class instantiated, which superficially are identical, but which Java considers unique. So what should be a perfectly legitimate portableObjectNarrow() will fail. I think if you pull the EJB from the servlet classpath, internal WebLogic magic will still find the EJB for the servlet, but your message will go away.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: EJB with Weblogic 5.1
It's not a secret anymore!