Errata

Enterprise JavaBeans

Errata for Enterprise JavaBeans

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Printed Page 27
Code for Home and Bean Class

After typing the code in for the remote interface, home interface, bean
class and the PK class, I tried to create an enterprise bean in Visual Age
for Java 3.5. I receive an error stating the CabinBean does not have the
method "findByPrimaryKey" in it that the CabinHome interface has
defined. What would this look like in the CabinBean code???

Anonymous   
Printed Page 57
Last paragraph

The six primary services are not new concepts; the OMG defined interfaces
for a most of them...

should be:

The six primary services are not new concepts; the OMG defined interfaces
for most of them...

Anonymous   
Printed Page 69
Top paragraph

However, JRMP, is has...

should read:

However, JRMP, has...

Anonymous   
Printed Page 84
1st paragraph

CabinHome Interface won't compile even if you compile it after compiling Cabin
Interface and CabinPK clas as the book says.
The compiler detects 3 errors like:
"cannot find Cabin and CabinPK.

Anonymous   
Printed Page 85
import statements

The CabinBean.java class will not compile. It seems that an extra import
statement is required: "import javax.transaction.UserTransaction;".
However, this doesn't seem to solve the problem entirely, as the compiler
then states that the javax.transaction.UserTransaction class cannot be
found.

Anonymous   
Printed Page 93
5th paragraph

"Copy the Cabin bean's deployment descriptor into the same directory as the
class files for the Cabin bean files (...) and save it as ejb-jar.xml."

This is a contradiction to p. 91, paragraph 1, where is written:

"... this ejb-jar.xml file must be in the JAR as META-INF/ejb-jar.xml in
order for it to be found."

Anonymous   
Printed Page 94
The graphic on page 94 is false

The META-INF directory has to be put in the directory dev, otherwise the
jar-command on page 100 (jar cf cabin.jar com/titan/cabin/*.class
META-INF/ejb-jar.xml) makes no sense.

Anonymous   
Printed Page 94
Figure 4-2

CabinBean.java is missing from the hierarchy in the diagram.
CabinBean.class is there, but not the source file.

Anonymous   
Printed Page 94
figure 4-2

the tree is missing CabinBean.java (not sure if this is an error or not)

Anonymous   
Printed Page 104
At the bottom of the page

Performing a lookup refer to the remote interface. This means that the
following line should be changed from:

Object ref = jndiContext.lookup("CruiseHome");

to:

Object ref = jndiContext.lookup("com/titan/cabin/Cabin");

including the specific package path for the interface.

Anonymous   
Printed Page 104
Code at bottom

As written, this code did not compile. I had to add

import javax.rmi.PortableRemoteObject;

at the top. Ditto for the definition of Client_2 on page 109.

Anonymous   
Printed Page 104
Code at bottom

I had to change this line:

Object ref = jndiContext.lookup("CabinHome");

to:

Object ref = jndiContext.lookup("CabinBean");

The Client_1 application was throwing a NamingException because it couldn't
find anything bound to the name "CabinHome".

If this is an error, then it needs to be fixed in the third code segment on
page 106 as well.

Anonymous   
Printed Page 123
The fifth line, which reads

dev % jar cf cabin.jar com/titan/tralvelagent/*.class M...

should read:

dev % jar cf TravelAgent.jar com/titan/travelagent/*.class
com/titan/travelagent/M...

Same with the line below.

Anonymous   
Printed Page 139
2nd paragraph

1.
"Any class that implements the EJBMetadata interface must be serializable..."

and must be a valid RMI/IDL value type.

2.
code listing of definition for EJBMetaData interface
1. interfaces do not use abstract keyword
2. EJBMetaData interface also has method: boolean isStatelessSession

Anonymous   
Printed Page 142
Figure 5-4

Figure 5-4 shows javax.ejb.EJBObject extending javax.rmi.Remote.
Actually, Remote is in the package java.rmi.

Anonymous   
Printed Page 149
Code snippet

Cabin cabin_2 = CabinHome.findByPrimaryKey(primaryKey);

should be:

Cabin cabin_2 = home.findByPrimaryKey(primaryKey);

Anonymous   
Printed Page 161
Code snippet

In the ejbCreate() method definition, the java.lang.Object should be the
argument of the method and not the return type.

Anonymous   
Printed Page 165
In the middle of the page

Ship myself = (Ship)context.getEJBObject();

should be:

EJBObject obj = context.getEJBObject();
Ship myself = (Ship)PortableRemoteObject.narrow(obj, Ship.class);

Anonymous   
Printed Page 169
First paragraph, fourth sentence

The following sentence:

In EJB 1.0, this is not possible because Java won't allow you to overload
methods with different return values.

Should read:

In EJB 1.0, this is not possible because Java won't allow you to override
methods with different return values.

Explanation
-----------
Java allows overloaded methods to return different values however overriden
methods are not allowed to return different values as defined by the Java
Language Specification, section 8.4.6.3 - Requirements in Overriding and
Hiding:

If a method declaration overrides or hides the declaration of another
method, then a compile-time error occurs if they have different return
types or if one has a return type and the other is void.

Anonymous   
Printed Page 178
In the code for class Client_1.main()

The line:

PortableRemoteObjectnarrow(ref, ShipHome.class);

should read:

PortableRemoteObject.narrow(ref, ShipHome.class);

Anonymous   
Printed Page 186
Last line of paragraph below heading Exception Handling

The line:

exceptions, which are throw from ...

should read:

exceptions, which are thrown from ...

Anonymous   
Printed Page 188
The hypothetical example is all messed up

public class A_Bean extends EntityBean {

should be:

public class A_Bena implements EnityBean {

...

EJBObject obj = context.getEJBObject();
A_Bean myself = (A_Bean)PortableRemoteObject.narrow(obj, A_Bean.class);

Attempts to narrow to a bean class instead of remote interface.

Anonymous   
Printed Page 202
ejbLoad()

In ejbLoad below the: "if (result.next())) {", the assignment for id is:
"id = id"

it should be:

"id = pk.id".

Anonymous   
Printed Page 204
third code block

Should be:

public class ShipBean implements javax.ejb.EntityBean {

public ShipPK ejbFindByPrimaryKey(ShipPK primaryKey)
throws FinderException {}
public Enumeration ejbFindByCapacity(int capacity)
throws FinderException {}
}

In particular: The class should implement the interface, not extend
it. The finder methods should not throw RemoteException for EJB
1.1. RemoteException should only be thrown for EJB 1.0 so this should be
documented after the code block or included as an additional code block.

Anonymous   
Printed Page 221
Section "Downloading the Missing Pieces"

In the two downloaded source files CruiseBean.java and
ReservationBean.java, change:

public javax.ejb.EntityContext ejbContext;

to:

private javax.ejb.EntityContext ejbContext;

These fields are NOT to be persisted, and therefore should not be public,
especially when CMP is being employed.

Anonymous   
Printed Page 222
download Examples.zip

Basically this is an errata to an existing {222} errata

As of March 31st/2001 the dowloaded example code no longer has a EJB1.0
Client.java in the EJB 1.1 directories.

Now 3 Client.java files are completely missing from the following
3 EJB directories:

chapter7EJB11com itancruise
chapter7EJB11com itancustomer
chapter7EJB11com itan eservation

The solution would be to copy the Client.java files from
the corresponding EJB10 directories and make the EJB 1.1
'narrow'ing modification necessary to ~cast~ the 1.1 way.
See the {222} errata for an example.

Anonymous   
Printed Page 258
2nd paragraph

States that ReservationBean throws a DoubleBookedException (which is a custom e
xception), but in the downloadable code, this exception does not exist and is n
ot thrown.

Anonymous   
Printed Page 302
EJB 1.1 Example at bottom

UserTransaction tran = ...
...
utx.begin();

... Should read:

UserTransaction utx = ...
...
utx.begin();

Anonymous   
Printed Page 307
The interface definition of UserTransaction

The line :

public abstract void begin(){
throws IllegalStateException, SystemException;

should read:

public abstract void begin(){
throws NotSupportedException, SystemException;

Anonymous   
Printed Page 329
Code listing at bottom of page

Incorrect code:

// Address as a persistent field
public class Person extends javax.ejb.EntityBean {

Should be:

// Address as a persistent field
public class Person implements javax.ejb.EntityBean {

The same error is repeated at the top of page 330. In keeping with the
naming convention used throughout the rest of the book, _Person_ should
also be changed to _PersonBean_.

Anonymous   
Printed Page 359
Object To Reltional Mapping Tools, 3rd paragraph

Toplink is nolonger from Object People. It is now from a company called
WebGain. Check out www.webgain.com for more info.

Anonymous   
Printed Page 376
Under "References to Other Beans" a mistake has slipped in.

It says:

"The env-ref element is used..."

but it must be:

"The ejb-ref element is used..."

Anonymous   
Printed Page 376
In the businessMethod() method

1. Either replace:
createQueueSession(true,0)
with:
createQueueSession(false,Session.AutoAck),

OR insert:
session.commit();
immediately before:
connect.close();

2. Insert:
connect.start();
immediately before:
TextMessage textMsg = (TextMessage) receiver.receive();

Anonymous   
Printed Page 379
Second bullet (top of page)

Text reads "javax.net.URL"
Should read "java.net.URL" (there is no javax.net package)

Anonymous   
Printed Page 437
Table C-2

www.eboss.org EJBoss

should be:

www.jboss.org JBoss

[examples.zip] Examples.zip Download, ch6/EJB11/BMP/com/titan/ship/ejb-jar.xml;
Line 25 should be the closing tag:
</resource-ref>

Instead it is missing the /

Anonymous