你的ejb代码似乎没有问题,可是你的client的代码呢?
贴出来看看?
还有ias的配置?
最好老老实实按照例子来做一遍的说。

解决方案 »

  1.   

    原来大家入手ejb都是用这个例子啊!!!!getTellNo!!!

      

  2.   

    很老实的按照离子来做的了
    client代码如下:import javax.naming.*;
    import javax.rmi.PortableRemoteObject;public class Client {
          private TellerHome tellerHome = null;      /**Construct the EJB test client*/
          public Client() {
                try {
                      //get naming context
                      Context ctx = new InitialContext();                  //look up jndi name
                      Object ref = ctx.lookup("TellerHome");                  //cast to Home interface
                      tellerHome = (TellerHome) PortableRemoteObject.narrow(ref, TellerHome.class);                  Teller teller = tellerHome.create();
                      int t = teller.getTellerNo();
                      System.out.println("Using Teller No is: " + t);
                }
                catch(Exception e) {
                      e.printStackTrace();
                }
          }      //----------------------------------------------------------------------------
          // Utility Methods
          //----------------------------------------------------------------------------      public TellerHome getHome() {
                return tellerHome;
          }
          /**Main method*/      public static void main(String[] args) {
                Client client = new Client();
                // Use the getHome() method of the client object to call Home interface
                // methods that will return a Remote interface reference.  Then
                // use that Remote interface reference to access the EJB.
          }
    }在j2ee自带的server里就可以访问(属于本地访问吧?需不需要专门的for ias的访问
    代码?),不过用ias就不行了。