且看下面的代码就是我描述的情形:
比如第一个ejbCreate方法与第三个方法参数基本一样,其的第二个参数本来CustomerRemote customer,编译后成了String customerid,变成完全与第三个方法参数一样,所以出现“"OrderBean.java": Error #: 450 : duplicate definition of method ejbCreate(java.lang.String, java.lang.String, java.util.Collection) in class jasmine.OrderBean at line 255, column 16
”错误。
/**
 * Called when new database data is created.
 *
 * When the client calls the Home Object's create() method,
 * the Home Object then calls this ejbCreate() method.
 *
 * We need to initialize our Bean's state with the parameters
 * passed from the client by calling our own abstract set
 * methods.  The Container can then inspect our Bean and
 * INSERT the corresponding database entries.
 */
public String ejbCreate(String orderID, String customerID, Collection lineItems) throws CreateException {
System.out.println("Order.ejbCreate(" + orderID + ") called");
            this.setOrderid(orderID);
            this.setOrderDate(new java.sql.Timestamp(System.currentTimeMillis()));
            this.setStatus("submitted");
        /*
         * CMP entity beans' ejbCreate() always return null.
         * The ejbCreate() method has a non-void return signature so
 * that the ejbCreate() signature matches that of a
 * BMP entity bean, allowing you to create a BMP entity bean
 * that subclasses a CMP entity bean.
 */
    try {
                Context ctx = new InitialContext();
                CustomerRemoteHome home = (CustomerRemoteHome)
                    javax.rmi.PortableRemoteObject.narrow(
                        ctx.lookup("CustomerRemoteHome"), CustomerRemoteHome.class);
                CustomerRemote c = home.findByPrimaryKey(customerID);
                return this.ejbCreate(orderID, c, lineItems);
        }catch (Exception e) {
            e.printStackTrace();
            throw new EJBException(e);
        }
        }
    /**
 * Called when new database data is created.
 *
 * When the client calls the Home Object's create() method,
 * the Home Object then calls this ejbCreate() method.
 *
 * We need to initialize our Bean's state with the parameters
 * passed from the client by calling our own abstract set
 * methods.  The Container can then inspect our Bean and
 * INSERT the corresponding database entries.
 */
public String ejbCreate(String orderID, String customerID, String status, double subTotal, double taxes) throws CreateException {
System.out.println("Order.ejbCreate(" + orderID + ") called");
        this.setOrderid(orderID);
        this.setOrderDate(new java.sql.Timestamp(System.currentTimeMillis()));
        this.setStatus(status);
        this.setOrderSubTotal(subTotal);
        this.setOrderTaxes(taxes); /*
 * CMP entity beans' ejbCreate() always return null.
 * The ejbCreate() method has a non-void return signature so
 * that the ejbCreate() signature matches that of a
 * BMP entity bean, allowing you to create a BMP entity bean
 * that subclasses a CMP entity bean.
 */
    try {
                Context ctx = new InitialContext();
                CustomerRemoteHome home = (CustomerRemoteHome)
                    javax.rmi.PortableRemoteObject.narrow(
                        ctx.lookup("CustomerRemoteHome"), CustomerRemoteHome.class);
                CustomerRemote c = home.findByPrimaryKey(customerID);
                return this.ejbCreate(orderID, c,status,subTotal,taxes);
        } catch (Exception e) {
            e.printStackTrace();
            throw new EJBException(e);
        }
} /**
 * This ejbCreate() accepts a String as a customer, and looksup the customer
 * on behalf of the client
 */
public String ejbCreate(String orderID, String customerID, Collection lineItems) throws CreateException {
        try {
                Context ctx = new InitialContext();
                CustomerRemoteHome home = (CustomerRemoteHome)
                    javax.rmi.PortableRemoteObject.narrow(
                        ctx.lookup("CustomerRemoteHome"), CustomerRemoteHome.class);
                CustomerRemote c = home.findByPrimaryKey(customerID);
                return this.ejbCreate(orderID, c, lineItems);
        }catch (Exception e) {
            e.printStackTrace();
            throw new EJBException(e);
        }
    }    /**
 * This ejbCreate() accepts a String as a customer, and looksup the customer
 * on behalf of the client
 */
public String ejbCreate(String orderID, String customerID,String status, double subTotal,double taxes) throws CreateException {
        try {
                Context ctx = new InitialContext();
                CustomerRemoteHome home = (CustomerRemoteHome)
                    javax.rmi.PortableRemoteObject.narrow(
                        ctx.lookup("CustomerRemoteHome"), CustomerRemoteHome.class);
                CustomerRemote c = home.findByPrimaryKey(customerID);
                return this.ejbCreate(orderID, c,status,subTotal,taxes);
        } catch (Exception e) {
            e.printStackTrace();
            throw new EJBException(e);
        }
    }