Yes it does look as if you may have found a mistake in the book.  The only 
definitive guide is the EJB specification available for download from Sun.

>From oreilly the session bean chapter can be downloaded for free for the 4th 
>edition.  The example does show as you say that the InitialContext is 
>referenced and not handled by ejbPassivate and ejbActivate.  At the end of the 
>chapter it does however go on to say that the bean can only hold onto a 
>javax.naming.Context if it references the JNDI ENC.

The setSessionContext should be rewritten as: -


  | public void setSessionContext(javax.ejb.SessionContext cntx) {
  |   ejbContext = cntx;
  |   try {
  |     Context context = new InitialContext();
  |     jndiContext = context.lookup("java:comp/env");
  |   } catch(NamingException ne) {
  |     throw new EJBException(ne);
  |   }
  | }
  | 

Then all lookups using the jndiContext should ommit the "java:comp/env".

I expect that the reason this has not been discovered sooner is because when 
executed the client will be calling remove before the need for passivation so 
noone will have seen the bean being passivated.

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3870451#3870451

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3870451


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to