Problem with PortableRemoteObject.narrow
843829Jan 23 2004 — edited Jan 27 2004Hi,
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!