访问EJB时出错,请帮忙
本人写了一个无状态SESSION BEAN ,在SUN APPSERVER 上成功发布,但用WEB方式访问时却出错了.客户端的代码如下:
public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
{
String str = "" ;
try
{
Context ct = new InitialContext() ;
Object ob = ct.lookup("HelloBean") ;
if (ob != null )
str = "HelloBean finded\r\n";
HelloHome helloHome = (HelloHome) PortableRemoteObject.narrow(ob, HelloHome.class) ;
str = str +" HelloHome finded\r\n";
Hello hello = helloHome.create();
str = str +"helloHome.create() success\r\n";
str = str +"run hello.sayHello() \r\n";
str = str +hello.sayHello("my boy") ;
str = str + "run success \r\n";
httpServletRequest.setAttribute("message",str);
return actionMapping.findForward("forward");
}
catch(Exception ex)
{
str = str + "cause an exception \r\n";
httpServletRequest.setAttribute("message",str+ex.toString());
return actionMapping.findForward("forward");
}
}
在JSP页面中出现的信息如下:
HelloBean finded cause an exception java.lang.ClassCastException
请问,这是什么原因呢?