Head First EJB by Kathy Sierra, Bert Bates This errata page lists errors outstanding in the most recent printing. If you have technical questions or error reports, you can send them to booktech@oreilly.com. Please specify the printing date of your copy. This page was updated February 25, 2008. 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 ?page-number?: reader question or request for clarification ------------------------------------------ HELPFUL NOTE FROM AUTHORS: Hello! We have discovered something that -- while not being an errata -- is a bug in the J2EE software that is showing up in our main opening tutorial exercise. Here it is... for the chapter 1 Advice Guy application (not tied to a specific page) If you receive a CORBA.BAD_OPERATION error when you run the client, you may be experiencing a bug that exists in some versions of the J2EE Reference Implementation. The R.I. bug is: * You can't have a method name that has the same characters as the interface name. Remember, this is a bug in the RI, and NOT a rule from the EJB spec. * In the Advice application, the interface currently looks like this: public interface Advice extends EJBObject { public String getAdvice() throws RemoteException; } The problem is that getAdvice() contains the characters "Advice" that match the interface name, and this *can* in some systems, cause the bug. We can't specify exactly which combination of versions and OS produces the problem, except to say that the Linux distribution of J2EE 1.3.1 on Max OSX 10.2 and 10.3 does not have a problem. The FIX is: 1) Change the business method name to something else in the interface: public interface Advice extends EJBObject { public String getTheMessage() throws RemoteException; } 2) Change the business method implementation in the bean class to match. 3) Change the client code that calls the method, to reflect the new method name. 4) Undeploy the current version and cleanup the server using; * run "cleanup" (without the quotes) at the command-line (this will undeploy your application and take the server back to the state it was in when installed.) * Delete your existing .ear file (and any .temp files, if you see them in your projects or Advice directory) 5) Restart the server and restart deploytool 6) Recreate the application and the bean (using New --> Enterprise bean) and start over. 7) Be sure to wear your 'lucky t-shirt' while doing this. The R.I has been known to respond to some forms of superstition. Or maybe it's just an urban legend... 8) Run the client again and voila! Success! Finally! -------------------------------------------------------- Confirmed errors: (4) Last paragraph, first sentence; XML is spelled here with a lower-case 'L': "... simply by tweaking an XMl document at deploy-time." 'L' should be upper-case. (24) handwriting note on the upright; in this book, we won't use the JAR tool to make the ejb-bar ourselves; the "ejb-bar" should be "ejb-jar" (29) java files under advice/src/headfirst; under fourth file folder on bottom row ",java files" should be ".java files". (61) paragraph at bottom; The sentence "How does the client call methods it?" should be: "How does the client call methods ON it?" (62) 1st paragraph; "depends on your understanding what's in this chapter." should be "depends on your understanding of what's in this chapter." [94] steps 5 and 6; The order of creation is wrong (and inconsistent with the order as present later in the book): The EJBObject is created BEFORE the bean is created. Steps 5 and 6 are really 3 steps: Now the services kick in and 5: the EJBObject is created 6: the bean is created 6b: the EJBObject stub is returned to the client. (101) item #3; The Home container steps in and adds its services. should be: The Home object steps in and adds its services. (108) First column heading reads "Stateful Session Beans" It should say: "Stateless Session Beans" (125) last line on the page; Says "primtive" should be "primitive" (130) A:, second line; "a session bean, he can't call the ..." should be "a session bean, she can't call the ..." (137, 138, 141, 151) "EJBObject" interface boxes. "isIdentical(Object o)" should read "isIdentical(EJBObject o)" {139} Side notes; 2nd Paragraph of the sidebar notes : It has just one method, getEJBObject(), that returns type Object. It should be type "EJBObject". (154) Very bottom right "EJBLocalObject" interface box. "isIdentical(Object o)" should read "isIdentical(EJBLocalObject o)" (160) 4th line in the last note; Note says "getAdvice() doesn't declare any excpetions,". "excpetions" should be "exceptions" [163] 2nd diagram; The text inside the second diagram, which reads "BEFORE: 1 dog, 2 references" should read "AFTER: 1 dog, 2 references" (175) objective 3.5, line 2; identify misspelled as "indentify" (175) Offical objective 3.6, at the end; The last expression ', remote component interface' should be ', local home interface' otherwise the remote component interface is mentioned twice and local home interface never. {222} Stateful session beans , last bullet point; says: "...or the bean times out)" should be: "...or the bean times out, or the bean throws a system exception)" (235) all over; The numbering of the rules is wrong: 1, 2, 3, 2, 3, 4 instead of 1 to 6 (239) above the Bean Provider image; invoking ejbPassivate() is printed as invoking ebjPassivate() {246} Question 8; C. The provider must close any database connections before ejbPassivate() completes. should say: C. The provider must not close any database connections before ejbPassivate() completes. (246) question 8, option E; instead of "...will be not survive passivation..." should read: "...will not survive passivation..." (247) Question 10, Method E; The interface javax.ejb.SessionContext contains no method named getRollBackOnly. But it contains a method with the name getRollbackOnly. The Answer on page 254 has the same typo. (261) 1st sentence in 1st paragraph; Change "An entity bean is an object-oriented way of looking at in a persistent store." should be: "An entity bean is an object-oriented way of looking at a persistent store." (268) Method getFirstName(); On page 268, the method getFirstName() returns the lastName instead of the firstName. public String getFirstName() { return lastName; } should be public String getFirstName() { return firstName; } (285) 3rd Paragraph on left, 6th line "S ometimes" should read "Sometimes" (296) What it really means: 1st paragraph, 4th line; change "javax.ejbEntityBean" TO "javax.ejb.EntityBean" (296) right column, second paragraph, fourth line; says "heal-living objects" and should be "heap-living objects". (301) step 4 paragraph, third line; says "nobody can except the bean can change" and should be "nobody except the bean can change". (304) Answer to the 'Dumb Question' in the right column; The third sentence in the first paragraph of the answer to the question "Doesn't BMP give you more control?" reads: "Things like ganging multiple calls to the database, using native code to get in an out of the database faster than you could, ..." it should be: "Things like ganging multiple calls to the database, using native code to get in and out of the database faster than you could, ..." (331) middle of page; Book says: "When ejbCreate(), the Container..." should be: "When ejbCreate() completes, the Container..." (333) 1st paragraph in the right side notes; An extra "the" in the 1st paragraph in the right side notes. "By the end of ejbCreate(), you must have a valid primary key assigned to the CMP field that you've the told the..." should be: "By the end of ejbCreate(), you must have a valid primary key assigned to the CMP field that you've told the..." (334) Last sentence in second paragraph; ...access to your EJB object (or something else that can happen only in ejbPostCreate(), and not in ejbCreate(). should be: ...access to your EJB object (or something else that can happen only in ejbPostCreate(), and not in ejbCreate()). (335) public Customer create(...) throws CreateException, RemoteException);; There is a ')' that doesn't belong after a RemoteException declaration in the create() method of the Home Interface. (351) There are two #7 steps and no #5 step. (352) Last line of page; Line says "The Container can call ejbStore() and ejbStore() at other times" should be "The Container can call ejbLoad() and ejbStore() at other times" (356) 3rd Paragraph; In the 3rd paragraph, "Commit option C": "... - a bean comes out of the pool, is activated, the loaded,..." It should be "... - a bean comes out of the pool, is activated, then loaded,..." (357) First "Q:"; Change "How does these commit options affect me?" TO: "How do these commit options affect me?" (358) 3rd answer, 2nd paragraph; "... have to be certain that all instances of that entity bean in sync, not just with..." should be: "... have to be certain that all instances of that entity bean are in sync, not just with..." [369] Question 9; The answer to question 9 should not have B checked. The EBJObject is not available during an entity bean's ebjCreate() (373) last line; (think: vendor/databse independent) should be: (think: vendor/database independent) [374] 1st paragraph on right; "container-managed persistent (CMR) fields" should be "container-managed relationship (CMR) fields" (379) 2nd paragraph. "What is the database..." should read "What if the database..." (382) 1st paragraph; return type of getDirector() is Director() should be return type of getDirector() is Director (389) "handwritten" note for point A-1; The second sentence in the note reads: "Se we expect that Director will have a CMR field with a Collection type rather than a single Movie" It should read: "So we expect that Director will have a CMR field with a Collection type rather than a single Movie." (389) "handwritten" note for point A-3; The "" tag after the end of the sentence was inadvertent and can be removed (394) Second "handwritten" note on the right side of the page; The last sentence in the note is missing a period at the end. (401) first paragraph, second line; says "lets you write SQL-like statements write into the" should be "lets you write SQL-like statements right into the" (402) 2nd subheader; "In the the deployment descriptor" should read "In the deployment descriptor" (403) Method header; Looks like the header got copied from the previous page. The header should be: public abstract Collection findByGenre(String genre) throws FinderException; (415) The handwritten note in the middle left of the page; The last sentence of the note reads: The query returns a set (no duplicates because we said "DISTINCT" of Directors it should be: The query returns a set (no duplicates because we said "DISTINCT" of Directors). (419) second handwritten note, third line; (Hey, phone numbers can to be Strings, they... should be (Hey, phone numbers can be Strings, they... (420) 7th bullet point; missing second double quotation mark after "abstract-persistence-schema" (424) last hand-written note; says "returns Movie1, not that it has been assigned" should be "returns Movie1, now that it has been assigned" {426} q4, answer c; Answer c b1.getBar() = null should be b1.getFoo() = null (426) question 4, last choice; says "E. none of the above" and should be "D. none of the above". (437) last line; "and the container give it to a ...." should say "and the container gives it to a ..." (438) 2nd paragraph. "The only different is..." should read "The only difference is..." (438) right column, eighth line from the top; says "have a very simply lifecycle" should be "hava a very simple lifecycle". (442) 1st line; Client (Producer) send a message... Should read Client (Producer) sends a message... (443) First line; First line reads: "4. Container invokes the beans onMessage() method..." Should read: "4. Container invokes the bean's onMessage() method..." {446} 4th note; MessageDrivenContext extends EJBObject Should be MessageDrivenContext extends EJBContext [448] 1st paragraph; The statement "The class must implement javax.ejb.MessageDrivenBean and javax.ejb.MessageListener" should read "The class must implement javax.ejb.MessageDrivenBean and javax.jms.MessageListener" (450) last line; "..., os you simply won't see it." should read "..., or you simply won't see it." {482} second figure; The comment "Transactions are suspended when they get to a BMP Bean" should say "Transactions are suspended when they get to a BMT Bean" (500) the last paragraph in the left "BANG" note ; .....which means you MUST use only: *Requires *RequiresNew *Mandatory should be: .....which means you MUST use only: *Required *RequiresNew *Mandatory (500) top-right 'watch-it' heading; says "TWO attributes: Requires..." should be "TWO attributes: Required..." (504) handwritten note; In the handwritten note at the bottom of the page, the 2 occurrences of Requires should be Required (505) tag in the 2nd at the bottom of the page; Requires should be: Required (508) left column, 6th bullet; The book says: " ...to acknowledge a method..." Should be: " ...to acknowledge a message..." (513) questons section line 13; "using a session bean as as a " should be: "using a session bean as a " (513) Top left corner; Reads: "... because stateless session bean's aren't allowed to maintain..." Should read: "... because stateless session beans aren't allowed to maintain..." (529) second paragraph, 8th line; says "that nows how to deal" and should be "that knows how to deal" (543) Both code examples; Reads: "public interface BadService extend EJBLocalObject" Should read: "public interface BadService extends EJBLocalObject" Reads: "public interface GoodService extend EJBLocalObject" Should read: "public interface GoodService extends EJBLocalObject" (549) Under paragraph titled "Finder Exception" last line; "datbase" should be: "database" (550) First "answer" section on the page; "any bean with overloaded creates (or it's only create has args)" should read "any bean with overloaded creates (or its only create has args)" (553) speech bubble; "On, and let me guess--" should be "Oh, and let me guess--" {554} the sixth line from the bottom; NoSuchObectException is when the client still has a stub to ... NoSuchObectException should be NoSuchObjectException. It is missing a 'j' (557) Second heading; The heading- Transaction should be Exceptions [557, 560] 4th scenario; A session bean has no any means to call getPrimaryKey() on its context, since the SessionContext and EJBContext interfaces did not define getPrimatyKey(). A session bean can call it only on its EJBObject, and RemoteException or EJBException will be thrown. (559) 4th scenario, 2nd line of solution; Within the (): the word should be "remote" instead of "local" (it throws a RemoteException) (571) ChangePay UML Diagram ; reinburse() method should be reimburse() (599) Sixth sentence in the paragraph at the bottom of the page; "Maybe you hard-coded a tax-rate (remember-bean's can't access property files)." should be: "Maybe you hard-coded a tax-rate (remember-beans can't access property files)." (610) first left-margin hand-written note; says "not the read DB name" and should be "not the real DB name" {610} Second handwriting on the left side; In the book, concerning res-auth element value: "Either the Bean or the Container" should be: "Either the Application or Container" EJB spec. (p.423) says: "The Bean Provider indicates the sign-on responsibility by setting the value of the res-auth element to Application or Container." [611] headline half way down the page; "Resource Authorization" should read: "Resource Authentication". [611] bullet item 1 near bottom of page; "Container authorization means" should read: "Container authentication means" [611] bullet item 2 at bottom of page; "Application authorization means" should read: "Application authentication means" (611) Res Type 4; Text reads "javax.net.URL" Should read "java.net.URL" {614} The first "Watch It!" section, in title and first line; " must NOT..." Should be " must NOT..." (614) 2nd "Watch It!" section. "But is is SO..." should read "But it is SO..." (615) first paragraph, first line; says "one bean's EJB reference it to another bean" should be "one bean's EJB references another bean" (618) Security topic - first bullet; Change assign of the security domain and principal realm to the app TO: assign the security domain and principal realm to the app (620) first paragraph, first line; says "bean'sspecial" and should be "bean's special" [620] Guaranteed APIs section; "You must which..." Should say: "You must know which..."