当你输入任意用户名时:
//这里bean为空
process bean=home.findByPrimaryKey(id);
//这里抛出空指针错误
String ps=bean.getPassword(); 所以resultpage还是"/index.jsp"; 

解决方案 »

  1.   

    一般来说,你找不到bean时,抛出的是一个NotFoundException。就你这样写,不知道你的bean写的时候如果找不到返回的是一个null值么?最好把bean贴出来看看
      

  2.   

    结构写的比较乱,你应该将ejb_object单独出来,单独得文件生成远程得对象,
    static private E21Manager instance;  public E21Manager() {
        init();
      }  static synchronized public E21Manager getInstance() {
        if (instance == null) {
          instance = new E21Manager();
        }
        return instance;
      }  private void init() {
        try {
          System.out.println("InitialContext ---------------");
          Context ctx = new InitialContext();
          sE21NameService = (String) ctx.lookup("java:/comp/env/Edge21NameService");      String sRunTimeUser = "Edge21eccbrg";
          String sRunTimePwd = "abc123";      System.setProperty("java.naming.factory.initial",
                             "com.inprise.j2ee.jndi.CtxFactory");
          System.setProperty("ORBInitRef", sE21NameService);      System.setProperty("javax.rmi.CORBA.StubClass",
                             "com.inprise.vbroker.rmi.CORBA.StubImpl");
          System.setProperty("javax.rmi.CORBA.UtilClass",
                             "com.inprise.vbroker.rmi.CORBA.UtilImpl");
          System.setProperty("javax.rmi.CORBA.PortableRemoteObjectClass",
                             "com.inprise.vbroker.rmi.CORBA.PortableRemoteObjectImpl");
          System.setProperty("org.omg.CORBA.ORBClass",
                             "com.inprise.vbroker.orb.ORB");
          System.setProperty("org.omg.CORBA.ORBSingletonClass",
                             "com.inprise.vbroker.orb.ORBSingleton");      System.out.println("sE21NameService = [" + sE21NameService + "]");      log.log("sE21NameService = [" + sE21NameService + "]");
        }
        catch (Exception ex) {
          Timestamp ts = new Timestamp(System.currentTimeMillis());
          ex.printStackTrace(pw);
          log.error("***************** E21Manager - init ********************");
          log.error(sw.toString());
          log.error("***************** E21Manager - init ********************");    }
      }  public SCMInternetController2Remote getSCMInternetRemote() throws Exception {
        SCMInternetController2Remote remote;
        try {      Context ctx = new InitialContext();
          String contextStr = "edge21/scm2/SCMInternetController2";
          System.out.println("Node: " + contextStr);
          Object objRef = ctx.lookup(contextStr);
          SCMInternetController2Home scmInternetControllerHome = (
              SCMInternetController2Home) PortableRemoteObject.narrow(objRef,
              SCMInternetController2Home.class);
          remote = scmInternetControllerHome.create();
          return remote;
        }
        catch (Exception ex) {
          throw ex;
        }
      }
    然后用DAO的模式,得到所有的数据,在servlet中call DAO中的数据。