Errata

Enterprise JavaBeans 3.1

Errata for Enterprise JavaBeans 3.1

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 00
I forgot will update later

you forgot to update SessionContext and EJBContext Interfaces, in 3.1 there are additional methods wasCancelCalled() and getContextData() respectively.

perry  Jan 25, 2011 
PDF Page 20
code example

Several of the example code snippets in Chapter 3 use "prototype" and "function" as if they were Java keywords.

rbergerpa42  Jan 12, 2011 
Printed Page 37
Sample code for CalculatorIntegrationTestCase, in comment for field "calc."

Comment is "The EJB 3.1 no-interface view view of the CalculatorEJB." "View" is repeated.

Ken Hommel  Dec 19, 2010 
PDF Page 46
bottom

@Stateless
public class A_Bean implements A_BusinessRemote {
@Resource private SessionContext context;
public void someMethod( ) {
B_BusinessRemote b = ... // Get a remote reference to B_Bean.
A_BusinessRemote mySelf = getBusinessObject(A_BusinessRemote.class);
b.aMethod( mySelf );
}
...
}

Randolf Rothfuss  Sep 01, 2011 
PDF Page 46
bottom

@Stateless
public class A_Bean implements A_BusinessRemote {
@Resource private SessionContext context;
public void someMethod( ) {
B_BusinessRemote b = ... // Get a remote reference to B_Bean.
A_BusinessRemote mySelf = context.getBusinessObject(A_BusinessRemote.class);
b.aMethod( mySelf );
}
...
}

Randolf Rotfuss  Sep 01, 2011 
PDF, Other Digital Version Page 47
Second to last paragraph

The paragraph talks about the EJBContext.lookup() method and references a an "example just shown to obtain the cipher's passphrase" but this example first appears quite a bit later on page 59.

Andreas Ntaflos  Apr 29, 2011 
PDF Page 55
bottom

@Stateless(name = "EncryptionEJB")
@Local(EncryptionLocalBusiness.class)
@Remote(EncryptionRemoteBusiness.class)
public class EncryptionBean
{ ...

you don't need explicitly implements the businessinterfaces when you use @local and @remote

Randolf Rothfuss  Sep 01, 2011 
Printed Page 55
Last paragraph

Original text:
"The EJB name defaults to the unqualified (simple) name of the bean class if you initialize this attribute..."

Should have been:
"The EJB name defaults to the unqualified (simple) name of the bean class if you DO NOT initialize this attribute..."

Louise Elmose Eriksen  May 20, 2013 
Printed Page 82
6th paragraph

Text says a bean provider may optionally prohibit parallel invocations upon a particular stateful bean via the use of @javax.ejb.ConcurrencyManagement (with associated fig 7-4).

According to Java EE 6 API discussiong for this attribute
"This annotation may be applied to stateful session beans, but doing so has no impact on the semantics of concurrency management for such beans. The concurrency management type for bean-managed concurrency (BEAN) does not apply to stateful session beans."

Bruce Link  Jan 24, 2011 
PDF Page 82
6th paragraph

[Original]

A bean provider may also optionally prohibit parallel invocations upon a particular stateful session via the use of @javax.ejb.ConcurrencyManagement (Figure 7-4).

[Correction]

A bean provider may also optionally prohibit parallel invocations upon a particular stateful session via the use of @javax.ejb.AccessTimeout (Figure 7-4).

SATO Naoki  Jun 10, 2011 
PDF Page 83
Figure 7-4

[Original]

Figure 7-4. Concurrent requests upon the same session blocking until the session is available for use

[Correct]

Figure 7-4. Concurrent requests upon the same session throwing an exception without blocking

SATO Naoki  Jun 11, 2011 
Printed Page 84
3rd paragraph

Incorrect html reference for AtomicInteger (actually refers to AtomicBoolean)

Bruce Link  Jan 24, 2011 
Printed Page 87
2nd code snippet

in

AccessTimeout(timeout=... , unit=...)

the timeout attribute is not defined, value should be used instead.

Markos Fragkakis  May 02, 2011 
PDF Page 106
footer

REQUEST FOR CLARIFICATION
[book]
The security methods? getCallerPrincipal() and isCallerInRole()?also throw a RuntimeException if invoked on a MessageDrivenContext. When an MDB services a JMS message, there is no ?caller,? so there is no security context to be obtained from the caller.


One might think that is logical. but..???

[Specification : : JSR-318]
--5.4.13 Security Context of Message-Driven Bean Methods
A caller principal may propagate into a message-driven bean?s message listener methods. Whether this occurs is a function of the specific message-listener interface and associated messaging provider, but is not governed by this specification.

-- AND T4 (page 149)
Bean method can perform the following operations:
for message listener method, business method interceptor method

MessageDrivenContext methods: ... getCallerPrincipal, isCallerInRole,..
Thank you in advance for your Clarification

Anonymous  Jun 13, 2011 
PDF Page 107
2nd code snippet

getInt("email") should be getString("email")

Rodrigo Piovezan  Dec 31, 2011 
PDF Page 108 and 110
Various - see description

Apparently some copy and paste from the stateless bean lifecycle into the MDB lifecycle section has left the following behind:
Page 108 - footnote - "stateless bean" should be "MDB"
Page 110 - 2nd paragraph - "stateless session bean" should be "MDB"
Page 110 - footnote - "stateless bean" should be "MDB"
Page 110 - footnote - "stateless instances" should be "MDB instances"

Rodrigo Piovezan  Dec 31, 2011 
Printed Page 110
footnote

The footnote says:
"The duration of a stateless bean..."
but the footnote is made on a sentence about MDB's, so the text should have been
"The duration of a MDB..."

Louise  Jun 18, 2013 
Printed Page 116
Code snippet

The same parameter connectionFactory is injected twice - which wont compile.

Louise  Jun 18, 2013 
Printed Page 118
second paragraph, first code example in page

Is:
User user = getUser(); // Assume we have this from somewhere
...
MessageProducer producer = session.createProducer(topic);
ObjectMessage objectMsg = session.createObjectMessage();
// Error: ObjectMsg is the object we just created, hence should be lower case!
ObjectMsg.setObject(user);
// Error: We set out to create an objectMsg, so no point in sending a mapMsg, an object we do not have!
producer.send(mapMsg);

Should be:
User user = getUser(); // Assume we have this from somewhere
...
MessageProducer producer = session.createProducer(topic);
ObjectMessage objectMsg = session.createObjectMessage();
objectMsg.setObject(user);
producer.send(objectMsg);

Regards
Thomas

Thomas Locher  Feb 06, 2011 
Printed Page 130
2nd paragraph

The preceeding example code and text describe an Employee class, but the last sentence of "Entities are POJOs" refers to a Customer class.

Anonymous  Jun 06, 2011 
Printed Page 131
Code example in the middle of page.

In getTheWorldsBestGuitarist():

return cust;

should instead be

return trey;

Anonymous  Mar 27, 2012 
Printed Page 143
last paragraph

For persist() method text states "TransactionRequiredException is thrown if this method is invoked on a transaction-scoped persistence context." It should qualify this and add "and there is no transaction"

The same addition is necessary on p 144 for merge(), page 147 for remove(), page 148 for refresh()

Bruce Link  Jan 30, 2011 
Printed Page 145
code on 2nd paragraph

dave.setName(NAME_DAVE_NEW);
has absolutely no impact since it is run on the detached unmanaged object. Only
managedDave.setName(NAME_DAVE_NEW);
would be meaningful, in order to actually reflect this change to the EntityManager.

Achilleas Mantzios  Jan 17, 2012 
Printed Page 145
Code example.

The same NAME_DAVE_NEW is used both to create a new Employee dave and then to change Employee dave's name to a *new* value.

Perhaps NAME_DAVE should be used to create the original Employee dave, and NAME_DAVE_NEW used to give the Employee dave a new name.

Anonymous  Mar 27, 2012 
Printed Page 147
4th paragraph

[Original]
All object instances returned by find(), getResource(), or a query remain managed as long as...


[Corection]
All object instances returned by find(), getReference(), or a query remain managed as long as...


getReference() name is mistyped.

Surendra  Jan 15, 2012 
PDF Page 156
code sample

[Original]
@Column(name="employee_name", nullable=false, columnDefinition="integer")

[Correction]
@Column(name="employee_name", nullable=false, length=20)

SATO Naoki  Jul 10, 2011 
PDF Page 156
Last paragraph

[Original]
Using the @Column annotation, we set the name property?s column name to be employee_name and not nullable, and we set its database type to be an integer. We also set the VARCHAR length to 20.

[Correction]
Using the @Column annotation, we set the name property?s column name to be employee_name and not nullable. We also set the VARCHAR length to 20.

SATO Naoki  Jul 10, 2011 
Printed Page 183
8th line

Expected: REFERENCES "PUBLIC"."EMPLOYEE"(ID)

But: REFERENCES "PUBLIC"."EMPLOYEE"(MANAGER_ID)

Munkhbayar  Oct 01, 2013 
Printed Page 208
'Parameters' - both code examples

In the code you present, you define:

final String jpaQlQuery ...

and below this line, you treat it as it would be a Query object and not a String:

jpaQlQuery.setParameter(...)

I guess the "jpaQlQuery" variable should be used on EntityManager to create a Query and then on this query the setParameter(...) method should be invoked.

PedroKowalski  Aug 29, 2011 
Printed Page 223
The WHERE Clause and MEMBER OF

SELECT t
FROM Team AS t, IN (t.members) AS m, Employee AS e
WHERE
e = :myCustomer
AND
e MEMBER OF m.members

Is wrongly written. m in "IN (t.members) as m" resolves to *a* member not a collection of member's.

It should either be :

SELECT t
FROM Team AS t, Employee AS e
WHERE
e = :myCustomer
AND
e MEMBER OF t.members

or

SELECT t
FROM Team AS t, IN (t.members) AS m, Employee AS e
WHERE
e = :myCustomer
AND
e = m

Achilleas Mantzios  Jan 26, 2012 
Printed Page 237
Entity Listeners

there is no postInsert annotation. There is postPersist.

Achilleas Mantzios  Jan 26, 2012 
Printed Page 258
1st paragraph

under the ejb/referenceToMyEJB2 --> ejbs/referenceToMyEJB2

It is missing an 's'.

Markos Fragkakis  Mar 03, 2011 
PDF Page 258
1st paragraph

such as "javax.annotation.EJB" instead of "javax.ejb.EJB"

Richard Grin  May 14, 2013 
Printed Page 261
XML snippet

Closing tag for <ejb-local-ref> is </ejb-ref>.

Markos Fragkakis  May 06, 2011 
Printed Page 306
Top

The Code-Snippet will not work properly, in the case of an exception.
The finally-Block needs a second if-clause

finally
{
if (startOurOwnTx()) {
if (txManager.getStatus().equals(Status.STATUS_MARKED_ROLLBACK) ) {
txManager.rollback();
} else {
txManager.commit();
}
}
}


Robert Meintrup  Jun 18, 2012 
Printed Page 306
3rd paragraph

In the code block example, a UserTransaction variable is declared named "tran" but then another variable is used to manage the user transaction named "utx". It should be the same variable name.

UserTransaction tran = (UserTransaction)
jndiCntx.lookup("java:comp/UserTransaction");
utx.begin();
...
utx.commit();

should be:

UserTransaction utx = (UserTransaction) jndiCntx.lookup("java:comp/UserTransaction");
utx.begin();
...
utx.commit();

Duarte Figueira  May 01, 2017 
PDF Page 333,334
Last code snippet(333), First code snippet(334)

package org.ejb3book.annotations;
import java.lang.annotation.*;
@Target({ElementType.METHOD, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface JndiInjected {
String value();
}


@Stateless
public class MySessionBean implements MySession {
@JndiInject("java:/TransactionManager")
private javax.transaction.TransactionManager tm;
...
}

The annotation declared is not the one used in the Bean Class. The one
used in bean class is not even declared.

Anonymous  Aug 24, 2011 
PDF Page 333
Description of UserTransaction's methods

In the descriptions of the UserTransaction's interface methods says that IllegalStateException and SystemException are "checked" exceptions, when, actually, they are "unchecked" exceptions: http://stackoverflow.com/questions/6115896/java-checked-vs-unchecked-exception-explanation

JOAO HENRIQUE DA SILVA MASSAN  Jun 18, 2016 
Printed Page 387
Code listing for TravelAgentBean

The EntityManager em is declared twice, once specifically as private with a unitName qualifier in the injection annotation. I don't believe that is intentional.

Also, I just don't see where a processorService is injected into the ProcessorService. Am I missing something fundamental?

Joe Hubert  Aug 14, 2011 
PDF Page 410
First heading

The first heading on the page says "Obtain the source using Subversion SCM", but the SCM used is git. The heading should thus say "Obtain the Source Using Git SCM"

Pedro Henrique Rausch Bello  Dec 03, 2010 
PDF Page 412
Body of Test In-Container section

Arquillian provides a easy mechanism --> Arquillian provides an easy mechanism

Pedro Henrique Rausch Bello  Dec 03, 2010 
Printed Page 461
Paragraph EncryptionBean.java

I think that the Appendix C on Chapter 6 contains some code from chapter 5 (pages 461 - 482 repeat pages 430 - 451).

Markos Fragkakis  Nov 02, 2010 
Printed, Other Digital Version Page 645
Last paragraph

Javadoc for open() method reads: "Closes the school for Business", which is copied from the Javadoc of the method close(). Should be "Opens the school for Business".

Same mistake in the current version on Github.

Markos Fragkakis  Dec 14, 2010