Enterprise JavaBeans, Third Edition By Richard Monson-Haefel The following corrections were made to the 10/03 reprint: Here's a key to the markup: [page-number]: serious technical mistake {page-number}: minor technical mistake : important language/formatting problem (page-number): language change or minor formatting problem {8} In PersonServer source; public int getAge() { return age; 02. } NOW READS: public int getAge() { return age; } {10} First code sample PersonServer person = new PersonServer("Richard", 36); NOW READS: PersonServer person = new PersonServer("Richard", 34); [40] Cabin EJB's local home code example; public interface CabinHomeLocal extends javax.ejb.EJBHome { NOW READS: public interface CabinHomeLocal extends javax.ejb.EJBLocalHome { {68} paragraph 3 The CabinBean defines three fields: a String of type name, an int of type deckLevel, and an Integer of type id . NOW READS: The CabinBean defines three fields: name of type String, deckLevel of type int, and id of type int. [81] last line; EmployeeService NOW READS: CabinEJB [90] source code for ejbPostCreate(); public void ejbPostCreate(Integer id){ } NOW READS: public void ejbPostCreate(Integer id){ // Not implemented. } [103] 3rd paragraph, the code segment ; Object ref = jndiContext.lookup("CabinHome"); NOW READS: Object ref = jndiContext.lookup("CabinHomeRemote"); {103} 3rd paragraph; CabinHome home = (CabinHomeRemote) NOW READS: CabinHomeRemote home = (CabinHomeRemote) {109} code example - next to last line on page; jndiContext = new InitialContext(); NOW READS: jndiContext = getInitialContext(); [110] listing;code example jndiContext = new InitialContext(); NOW READS: jndiContext = getInitialContext(); {114} 5th line of XML; "to the Cabin EJB" NOW READS: "to the TravelAgent EJB". [114] last two lines; "jar cf cabin.jar" NOW READS: "jar cf travelagent.jar", in both command lines. {130} Code under the phrase "This application creates output like the following:"; com.titan.cabin.CabinHomeRemote com.titan.cabin.CabinRemote com.titan.cabin.CabinPK false NOW READS: com.titan.cabin.CabinHomeRemote com.titan.cabin.CabinRemote java.lang.Integer false [140] 2nd code segment; The code of setting jndiContext: javax.naming.Context ctx = new javax.naming.InitialContext() NOW READS: javax.naming.Context ctx = getInitialContext(); [174] last sentence of next-to-last paragraph; "...so a local interface cannot declared as a return type of a parameter of a remote interface." NOW READS: "...so a local interface cannot be declared as a return type of a parameter of a remote interface." [175](line in second code listing) AddressHomeLocal addrHome = (AddressHomeLocal)cntx.lookup("AddressHomeLocal"); NOW READS: AddressHomeLocal addrHome = (AddressHomeLocal) cntx.lookup("java:comp/env/ejb/AddressHomeLocal"); [176] 3rd line; public interface Customer extends javax.ejb.EJBObject { NOW READS: public interface CustomerRemote extends javax.ejb.EJBObject { [177]First code listing: Object ref = jndiEnc.lookup("SalesHomeRemote"); NOW READS: InitialContext cntx = new InitialContext(); Object ref = cntx.lookup("java:comp/env/ejb/SalesHomeRemote"); [178]In code listing AddressHomeLocal addrHome = (AddressHomeLocal)cntx.lookup ("AddressHomeLocal"); NOW READS: AddressHomeLocal addrHome = (AddressHomeLocal) cntx.lookup("java:comp/env/ejb/AddressHomeLocal"); [179] the client application code; CustomerHome home = (CustomerHomeRemote) javax.rmi.ProtableRemoteObject.narrow(obj, CustomerHomeRemote.class); NOW READS: CustomerHomeRemote home = (CustomerHomeRemote) javax.rmi.ProtableRemoteObject.narrow(obj, CustomerHomeRemote.class); and Customer customer = home.create(primaryKey); NOW READS: CustomerRemote customer = home.create(primaryKey); {191} 5th paragraph; "associated with its AddressHome field" NOW READS: "associated with its homeAddress field" {194} last paragraph; " on the Address EJB to point back " NOW READS: " on the CreditCard EJB to point back " {195} first line of the code; Customer customer = card.getCustomer(); NOW READS: CustomerLocal customer = card.getCustomer(); [198] 1st paragraph code block; Methods were missing abstract modifier. public abstract class CustomerBean implements javax.ejb.EntityBean { ... // relationship fields public java.util.Collection getPhoneNumbers(); public void setPhoneNumbers(java.util.Collection phones); public AddressLocal getHomeAddress();() public void setHomeAddress(AddressLocal local); NOW READS: public abstract class CustomerBean implements javax.ejb.EntityBean { ... // relationship fields public abstract Collection getPhoneNumbers(); public abstract void setPhoneNumbers(Collection phones); public abstract AddressLocal getHomeAddress(); public abstract void setHomeAddress(AddressLocal local); ... Also, on pg 198, PhoneBean class should have had an abstract modifier (second code listing on page 198) public class PhoneBean implements javax.ejb.EntityBean { NOW READS: public abstract class PhoneBean implements javax.ejb.EntityBean { {199} code example at top of page; // relationship fields public java.util.Collection getPhoneNumbers(); public void setPhoneNumbers(java.util.Collection phones); NOW READS: // relationship fields public abstract java.util.Collection getPhoneNumbers(); public abstract void setPhoneNumbers(java.util.Collection phones); {200} code example at top of page; public java.util.Collection getPhoneNumbers(); public void setPhoneNumbers(java.util.Collection phones); NOW READS: public abstract java.util.Collection getPhoneNumbers(); public abstract void setPhoneNumbers(java.util.Collection phones); {201} code example; public java.util.Collection getPhoneNumbers(); public void setPhoneNumbers(java.util.Collection phones); NOW READS: public abstract java.util.Collection getPhoneNumbers(); public abstract void setPhoneNumbers(java.util.Collection phones); [207] 2nd paragraph; " is postponed until the ejbPostCreate() method completes " NOW READS: " is postponed until the ejbCreate() method completes " {216} last code segment on page; "ReservationHomeLocal = ... get local Reservation home" NOW READS: "ReservationHomeLocal resHome = ... get local Reservation home" [232] The code listing AND the Second to last paragraph; public abstract String ejbSelectMostPopularCity() throws FinderException; NOW READS: public abstract String ejbSelectCity(AddressLocal addr) throws FinderException; (2nd to last paragraph) "Select methods can return the values of CMP fields.The ejbSelectMostPopularCit y() method,for example,returns a single String value,the name of the city refer enced by the most Address EJBs." NOW READS: "Select methods can return the values of CMP fields. The ejbSelectCity(AddressL ocal addr) method,for example,returns a single String value,the name of the cit y referenced by the Address EJB." {236}(first paragraph at top of page) " The AS operator is optional, but it is used in this book to help make the EJB QL statements more clear. " NOW READS: " The AS operator is optional (its assumed) and is used in many, but not all, of the examples in this chapter. " {242} middle of the page; For example, the following find method, findByShip(), is declared in the Cruise bean's local interface: public interface CruiseLocal extends javax.ejb.EJBLocalObject { public Collection findByShip( ShipLocal Ship ) throws FinderException; } NOW READS: For example, the following find method, findByShip(), is declared in the Cruise bean's local home interface: public interface CruiseLocalHome extends javax.ejb.EJBLocalHome { public Collection findByShip( ShipLocal Ship ) throws FinderException; } [245] << original entry said page 247 >> Code sample for ReservationHomeLocal; public interface ReservationHomeLocal extends EJBLocalObject { NOW READS: public interface ReservationHomeLocal extends EJBLocalHome { {277} last sentence of third paragraph " we create a primary key and return it to the container." NOW READS: " we return the primary key to the container." {281} second code segment; public class ShipBean extends javax.ejb.EntityBean { NOW READS: public class ShipBean implements javax.ejb.EntityBean { {289} First code block; If(this.name.equals(other.name) and NOW READS: If(this.name.equals(other.name) && [297] 1st paragraph; In our example, a new record is inserted into the CUSTOMER table. NOW READS: In our example, a new record is inserted into the SHIP table. [302] 1st code example; public interface CruiseHomeLocal extends javax.ejb.EJBLocalHome { public CruiseLocal create(String name, ShipLocal ship); public void setName(String name); public String getName(); public void setShip(ShipLocal ship); public ShipLocal getShip(); public double totalReservationRevenue(CruiseLocal cruise); } NOW READS: public interface CruiseHomeLocal extends javax.ejb.EJBLocalHome { public CruiseLocal create(String name, ShipLocal ship); public double totalReservationRevenue(CruiseLocal cruise); } [302] code example; (second code listing) public abstract class CruiseBean implements javax.ejb.EntityBean { public Integer ejbCreate(String name, ShipLocal ship) { setName(name); } ... public double ejbHomeTotalReservationRevenue(CruiseLocal cruise) { Set reservations = ejbSelectReservations(cruise); Iterator enum = set.iterator(); double total = 0; while(enum.hasNext()) { ReservationLocal res = (ReservationLocal)enum.next(); Total += res.getAmount(); } return total; } public abstract ejbSelectReservations(CruiseLocal cruise); ... } NOW READS: public abstract class CruiseBean implements javax.ejb.EntityBean { public Integer ejbCreate(String name, ShipLocal ship) { setName(name); } ... public double ejbHomeTotalReservationRevenue(CruiseLocal cruise) { Set reservations = ejbSelectReservations(cruise); Iterator enum = reservations.iterator(); double total = 0; while(enum.hasNext()) { ReservationLocal res = (ReservationLocal)enum.next(); total += res.getAmount(); } return total; } public abstract ejbSelectReservations(CruiseLocal cruise); ... } {303-304} 3rd Line; public class A_Bean extends EntityBean { public EntityContext context; public void someMethod() { B_Bean b = ... // Get a remote reference to B_Bean. EJBObject obj = context.getEJBObject(); A_Bean mySelf = (A_Bean)PortableRemoteObject.narrow(obj,A_Bean.class); b.aMethod( mySelf ); } ... } NOW READS: public class A_Bean extends EntityBean { public EntityContext context; public void someMethod() { B_BeanRemote b = ... // Get a remote reference to B_Bean. EJBObject obj = context.getEJBObject(); A_BeanRemote mySelf = (A_BeanRemote) PortableRemoteObject.narrow(obj,A_BeanRemote.class); b.aMethod( mySelf ); } ... } Pg. 555-Change to Index Entry for ejbSelectCity(AddressLocal addr) NOW READS: Entry for ejbSelectCity(AddressLocal addr), 232