Head First EJB Notes:


The best place to check for errata (and submit errata) is the O'Reilly web site .

You can also send an email directly to the authors at:

EJBErrata@wickedlysmart.com

(By the way, the "smart" in "wickedlysmart" refers to YOU, not us ; )


If you receive the dreaded 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 by running:

"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!


If you are having trouble with classpath issues or the R.I. tools, you might not have the environment variables correctly configured. You need to set the following four environment variables:

JAVA_HOME (points to your Java 2 SDK directory)

J2EE_HOME (points to your J2EE 1.3.1 SDK directory)

PATH (needs to include the /bin directory in the J2EE home directory)

CLASSPATH (needs to include the /lib/j2ee.jar in the J2EE home directory)

Example:

(Using the syntax for the default OSX shell--your syntax may vary, of course, especially if you're on Windows.)

setenv PATH ${PATH}:/Users/kathy/J2EEStuff/j2sdkee1.3.1/bin
setenv JAVA_HOME /usr
setenv J2EE_HOME /Users/kathy/J2EEStuff/j2sdkee1.3.1
setenv CLASSPATH .:${J2EE_HOME}/lib/j2ee.jar

 

 

 

Back to the EJB page...