我的怎么不行,import也用——以下是jsp页面代码
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" import="javax.naming.*" import="lee.*" import="javax.rmi.PortableRemoteObject" errorPage=""%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>我的Session Bean测试页面</title>
</head><body>
<div align="center">
  <h2>我的Session Bean测试页面</h2>
</div>
<%
    try
{
   Context ctx=new InitialContext();
   Object ref = ctx.lookup("helloWorld-demo");
   out.println("找到JNDI目标<p>");
       helloWorldHome hm = (helloWorldHome) PortableRemoteObject.narrow(ref, helloWorldHome.class);
   out.println("成功创建home接口<p>");
}
catch(Exception e)
{
   out.println("出错了~");
}%>
</body>
</html>
显示结果是(页面编译通过):找到JNDI目标
出错了~ 也就是无法创建home接口

解决方案 »

  1.   

    这个简单的ejb,用我自己的client都测试通过的
      

  2.   

    出错信息是java.lang.ClassCastException: Cannot narrow remote object to lee.helloWorldHome 有没有高手说说看啊
      

  3.   

    根据你的提供的出错信息
    猜测是由于jsp导入的remote跟home接口与ejb的中的remote,home接口没有放在同一个包中。
    注意:client中的remote,home接口应与ejb中的接口使用同一package语句。