Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problem with PortableRemoteObject.narrow

843829Jan 23 2004 — edited Jan 27 2004
Hi,

Although there are many topics about the ClassCastException with PortableRemoteObject, my problem seems a litte different. I have a web application (a.war) with a servlet , and an enterprise application (b.ear) with some EJBs. My servlet code is :

// inside doGet .... //MainFormBean is a JavaBean
jndiContext = new InitialContext();
ejbName = req.getParameter("ejb");
Object ref = (Object) jndiContext.lookup(ejbName + "EJB");
Class ejbHome ejbHome = Class.forName("mypackage." + ejbName + "EJBHome");
Class ejbObject = Class.forName("mypackage." + ejbName + "EJB");
EJBHome home = (EJBHome) PortableRemoteObject.narrow(ref, ejbHome);
EJBObject ejb = (EJBObject) ejbHome.getMethod("create", null).invoke(home,null);
MainFormBean response = (MainFormBean) ejbObject.getMethod("doMyMethod",parameterNames).invoke(ejb,parameterValues);

I'm using Jboss 3.2.2 with Tomcat 4.27. If a deploy a.war and b.ear after start jboss, all works fine. But, if i undeploy only b.ear and redeploy it (without restart jboss and without undeploy a.war), the ClassCastException occurrs with PortableRemoteObject. Someone knows why???

I don' t know how is the servlet behavior when using ejb.

thanks in advanced for any help!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 24 2004
Added on Jan 23 2004
4 comments
103 views