Hi Nick,
I seem to get the same problem ( orion returns a StatefulSessionHomeWrapper3 class
instead of session home resulting in class cast exception).
I have a feeling this has got something to do with jsps having different ClassLoader.
The demo news app does something like
pageContext.getPage().getClass().getClassLoader(...) in their taglibs.
I am using Resin now as the servlet engine it works fine( as resin is just another
java client for Orion and the same code works fine if i use it in a
test java client.)
Would prefer to use orion for everything instead of having separate web server but it
seems to leave with very little option.
BTW the bugs 37 and 45 have got resolved thanks to your efforts in posting them.
Cheers
Krishnan
-----Original Message-----
From: Nick Newman [mailto:[EMAIL PROTECTED]]
Sent: Thursday, September 14, 2000 1:45 PM
To: Orion-Interest
Subject: Re: EJB question
Hi Kit,
I'm not sure that I tell you for SURE why it failed, but here are a few
thoughts.
Firstly, I think that some of the code you write is unnecessary. What I
would have written is:
Context context = new InitialContext(); // No properties required
Object homeObject = context.lookup("java:comp/env/MyCart"); // Note the
required "java:comp/env/" prefix
CartHome home =
(CartHome)PortableRemoteObject.narrow(homeObject,CartHome.class);
Cart cart = home.create(); // No cast required - home.create() returns a Cart
But that probably didn't cause your problem. I would guess that it was
caused by a discrepancy between the class types specified in the XML and in
the code.
Firstly note that in the WEB-INF/web.xml you should have a section looking
something like the following:
<ejb-ref>
<ejb-ref-name>MyCart</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>com.acme.MyCartHome</home>
<remote>com.acme.MyCart</remote>
</ejb-ref>
(If you don't, the "lookup" will fail, even though it may have worked
without the "java:comp/env/" prefix.)
Then the error you have seems to be saying that what is in the <home> part
of the xml doesn't match the CartHome class that is being used in your Java
code.
Hope this helps!
Nick
At 03:05 PM 9/14/00 -0400, you wrote:
>
>
>Hi all
>
>I am trying to build a servlet client to look up an ejb.
>
>But, i got the following error.
>
>
>500 Internal Server Error
>
>java.lang.ClassCastException: CartHome_StatefulSessionHomeWrapper1
> at
>javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java, Compiled
>Code)
> at testCart.doGet(testCart.java, Compiled Code)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java,
>Compiled Code)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java,
>Compiled Code)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java,
>Compiled Code)
> at com.evermind.server.http.du.rr(JAX, Compiled Code)
> at com.evermind.server.http.du.forward(JAX, Compiled Code)
> at com.evermind.server.http.d5.rx(JAX, Compiled Code)
> at com.evermind.server.http.d5.rw(JAX)
> at com.evermind.util.f.run(JAX, Compiled Code)
>
>
>
>this is what i did to do the look up.
>
>
>final Properties properties = new Properties();
>
>properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,"com.evermind.server.
>ApplicationClientInitialContextFactory");
>
>properties.setProperty(Context.PROVIDER_URL,"ormi://localhost/ejbsamples");
>
>properties.setProperty(Context.SECURITY_PRINCIPAL,"username");
>
>properties.setProperty(Context.SECURITY_CREDENTIALS, "password");
>
>
>Context context = new InitialContext(properties);
>
>
>Object homeObject = context.lookup("MyCart");
>
>
>CartHome home =
>(CartHome)PortableRemoteObject.narrow(homeObject,CartHome.class);
>
>
>Cart cart = (Cart)PortableRemoteObject.narrow(home.create(), Cart.class);
>
>
>
>Can anyone tell me why it failed ?
>
>Thanks a lot.
>
>-kit
>