Title: RE: Interesting ejb Error!!!

I have seen ClassCastExceptions when narrowing an object obtained from another application.
I believe it's due to different class loaders for each app. If you're servlet is in another
app, then you have to set it's "parent" attribute (i.e. parent="ejbsamples" ) in the sever.xml.
Also I think you should be using ApplicationInitialContextFactory. ApplicationClientInitialContextFactory
is explicitly for external clients. But if you set the "parent" attribute then you shouldn't have to set
the JNDI properties. Just do "Context context = new InitialContext();"

If you're servlet is in the same app, then again you shouldn't have to set the JNDI props - the
container does that for you.

Either way ApplicationClientInitialContextFactory is not correct for a servlet.

-----Original Message-----
From: Andiappan Jeyamurugan
[mailto:[EMAIL PROTECTED]]
Sent: Wednesday, October 04, 2000 1:50 AM
To: Orion-Interest
Subject: Interesting ejb Error!!!


Hello there,
I am trying to access the orion's demo/ejb/cart ejbeans via servlet or jsp
file. The code is
                try
                {
                        Hashtable env = new Hashtable();
 
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.evermind.server.ApplicationClie
ntInitialContextFactory");
 
env.put(Context.PROVIDER_URL,"ormi://10.1.1.59/ejbsamples");
                        env.put(Context.SECURITY_PRINCIPAL,"admin");
                        env.put(Context.SECURITY_CREDENTIALS,"123");     
                Context context = new InitialContext(env);
                Object homeObject = context.lookup("java:comp/env/MyCart");
                        CartHome home =
(CartHome)PortableRemoteObject.narrow(homeObject, CartHome.class);
                        }
                //Cart cart =
(Cart)PortableRemoteObject.narrow(home.create(), Cart.class);
                 }
                catch(Exception ee){
                                return "Error Becomes ..."+ee;
                }
I am getting error as,
        java.lang.ClassCastException: CartHome_StatefulSessionHomeWrapper2

If I access the ejbeans from an application on command prompt, it is working
fine.
I really wonder why the same code is not working in servlet/beans/jsp.
Can anyone help me?

Thanks in advance
Jeya([EMAIL PROTECTED])
=====================================================================
WARNING -This e-mail, including any attachments, is for the
personal use of the recipient(s) only.
Republication and re-dissemination, including posting to news
groups or web pages, is strictly prohibited without the express
prior consent of
Thomson Legal & Regulatory Group Asia Pacific Ltd
ACN 058 914 668
=====================================================================

Reply via email to