马上运行是不可能的,至少要修改JDBC等资源的JNDI名才可以:以下主键实现类:
-----------------------------------------------------
package examples;import java.io.Serializable;public class AccountPK implements java.io.Serializable 
{
  public String accountID;  public AccountPK(String id) 
{
this.accountID = id;
  }  public AccountPK() 
{
  }  public String toString() 
{
return accountID;
  }  public int hashCode() 
{
   return accountID.hashCode();
  }
  
  public boolean equals(Object account) 
{
   return ((AccountPK)account).accountID.equals(accountID);
  }  
}

解决方案 »

  1.   

    HOME接口
    -----------------------------------------------------------------------------
    package examples;import javax.ejb.*;
    import java.util.Collection;
    import java.rmi.RemoteException;public interface AccountHome extends EJBHome 
    {   Account create(String accountID, String ownerName) throws CreateException, RemoteException;   public Account findByPrimaryKey(AccountPK key) throws FinderException, RemoteException;   public Collection findByOwnerName(String name) throws FinderException, RemoteException;   public double getTotalBankValue() throws AccountException, RemoteException;}
      

  2.   

    远程接口
    ----------------------------------------------------------------------
    package examples;import javax.ejb.*;
    import java.rmi.RemoteException;public interface Account extends EJBObject 
    { public void deposit(double amt) throws AccountException, RemoteException;
            
    public void withdraw(double amt) throws AccountException, RemoteException;
    public double getBalance() throws RemoteException; public String getOwnerName() throws RemoteException;
    public void setOwnerName(String name) throws RemoteException; public String getAccountID() throws RemoteException;
    public void setAccountID(String id) throws RemoteException;
    }
      

  3.   

    http://www-900.ibm.com/developerWorks/cn/wsdd/library/techarticles/lhtm/0210/bmpejb5.shtml