wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes Head First EJB: 1st tut error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Head First EJB: 1st tut error" Watch "Head First EJB: 1st tut error" New topic

Head First EJB: 1st tut error

Nitin Dindorkar

Joined: Nov 14, 2003
Posts: 6
I am trying to run the first tutorial from Head first EJB. I get following error after running the client. Please help.
C:\projects\advice>java AdviceClient
java.rmi.RemoteException: CORBA BAD_OPERATION 0 No; nested exception is:
org.omg.CORBA.BAD_OPERATION: minor code: 0 completed: No
org.omg.CORBA.BAD_OPERATION: minor code: 0 completed: No
at java.lang.Class.newInstance0(Native Method)
at java.lang.Class.newInstance(Unknown Source)
at com.sun.corba.ee.internal.iiop.messages.ReplyMessage_1_2.getSystemExc
at com.sun.corba.ee.internal.iiop.ClientResponseImpl.getSystemException(
at com.sun.corba.ee.internal.POA.GenericPOAClientSC.invoke(GenericPOACli
at org.omg.CORBA.portable.ObjectImpl._invoke(Unknown Source)
at headfirst._Advice_Stub.getAdvice(Unknown Source)
at AdviceClient.go(AdviceClient.java:19)
at AdviceClient.main(AdviceClient.java:9)
nick Hussein

Joined: Nov 16, 2003
Posts: 4
I am having the same problem. Can someone help us?
Chidu Chidambaram

Joined: Sep 18, 2003
Posts: 7
I am having the same problem. Please do post a reply if one of you can solve the problem.
Edward Mond

Joined: Nov 17, 2003
Posts: 1
I have this working in linux J2EE 1.3 without a problem. I checked the erata at www.ora.com for the HeadFirst EJB book, but nothing there.
Also, I don't have the same directory structure as they say in the book. Not that it matters, but it is a little different.
Also, I tagged the jar files for the client in FRONT of the CLASSPATH. Doesn't make much sense to tack them onto the end, especially if you have a lot of garbage in it. See my command line below...
Also, If I take j2ee.jar out of my path I get simular garbage to what you get....
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:640)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at AdviceClient.go(AdviceClient.java:19)
at AdviceClient.main(AdviceClient.java:11)

//here is is working...
[ed@top advice]# javac -classpath j2ee.jar/usr/java/j2ee/tutorial/examples/ears/AdviceAppClient.jar:${CLASSPATH} AdviceClient.java
[ed@top advice]# java -cp /usr/java/j2ee/tutorial/examples/ears/AdviceAppClient.jar:${CLASSPATH} AdviceClient
Eat it or flick it out the window!
[ed@top advice]# java -cp /usr/java/j2ee/tutorial/examples/ears/AdviceAppClient.jar:${CLASSPATH} AdviceClient
Where is the love?
Brian Smith
Ranch Hand

Joined: Oct 26, 2002
Posts: 232
hi folks
i have the same problem. Ok here is my client codes

The following is the exception thrown. if you look at the exception, the problem occurred when it tries to invoke the getAdvice() method in advice remote object. i don't have a clue WHY?

if you guys came up with the solution, PLEASE let me know.
Johannes de Jong

Joined: Jan 27, 2001
Posts: 5089
I had the same problem. I never fixed it as I assumed it had something to do with my "environment" (Windows XP, with WSAD 5.0 & IBM MQ). I intended running it on a "clean" machine but other things got in the way.
I will attempt to run it on a "clean" machine ASAP.
Could you guys please provide the "environments" you attempt to run the example on ie. Operating System, version of J2EE, version of SDK etc.
It might help solve the problem.
Kathy Sierra
Cowgirl and Author
Ranch Hand

Joined: Oct 10, 2002
Posts: 1572
Ah... the now-infamous CORBA.BAD_OPERATION error...

Sorry I didn't even think to come over to this forum and check; I'll do that from now on -- this discussion has been going on over in the EJB cert forum, but then Johannes alerted me to this discussion, so here I am.
O'Reilly should have something up in the next day or two about this.
Here's the deal:
1) There's a bug in the J2EE RI, that only appears in some implementations (not yet sure which). Obviously, it doesn't appear on my current set-up (Linux distribution of J2EE 1.3.1, J2SE 1.3.1, running under OSX 10.2 and 10.3)
2) The *official* bug at Sun is documented a little differently, but I talked with someone from the J2EE team today, and here's the story...
* You can get this error if you have a Remote interface name that has a business method with a name that has matching characters!! Yep, that's it. And this workaround will definitely fix the BAD_OPERATION problem, assuming you've done everything else correctly.
* So the problem is that we have an interface that looks like this:
public interface Advice extends EJBObject {
public String getAdvice() throws RemoteException;
// notice that getAdvice() contains a String matching the interface name. This is NOT a restriction of Java or even RMI, but once you get CORBA involved, naming problems can happen, and this is one...
3) To fix it, you need to:
* Change the component interface business method to something *other* than getAdvice(). So, you could change it to
public String getTheMessage() throws RemoteException
* Change the corresponding business method in the bean class
* Change the client code to invoke this method instead of getAdvice()
* Recompile everything.
* Now, you must recreate your enterprise bean and redeploy.
The safest way to do this (although it might be overkill) is to do the following:
* Run 'cleanup' (without the quotes) at the command-line. This will undeploy all of your applications (you probably only have one at this point), and restore the server to the way it was when you installed it. The logs are cleared, etc. along with the repository that holds your server's deployed applications.
* Be sure the server is shut down, and deploytool is shut down
* Delete your .ear file from your Advice directory (or wherever you have it).
* Delete any temp files that were put in that directory as well
* Restart the server
* Restart deploytool
* Start over making your AdviceApp, (follow the steps in the book again) and creating the bean... the only difference from the previous app is the name of the business method.
* Run your client
* Hold your breath (until it completes)
* Yay! Success.
Note: some people have found a different workaround, but it involves taking the classes out of their packages. Don't do this! Don't ask me why that workaround fixed this bug, but it's definitely not the right solution since you really do need these classes to be in packages.
So, keep *everything* exactly the same as it is in the book, except give the business method ANY name other than the one it has. And if you continue to use the RI, and you are on a system that produces this error, then keep that in mind when naming other business methods in other Remote interfaces.
And remember, if you *are* planning to take the exam, this naming problem is NOT an EJB rule -- it is simply a bug related to CORBA use in the RI.
OK, so far, everyone who has tried this fix has been successful, so we're certain that this is indeed the problem.
On the Sun site, we never even thought to check for a bug report on this since I've never had a problem (I've also tested this code under Solaris, but haven't tried it on a Windows machine under J2EE 1.3.1...)
cheers and thanks for your patience,
Thanks to the quick work of the javaranchers, we've solved the mystery of the RI...
You can go back to having fun now

Co-Author of <a href="http://www.amazon.com/exec/obidos/ASIN/0596007124/ref=jranch-20" target="_blank" rel="nofollow">"Head First Design Patterns"</a><br /> <br />Just a Jini girl living in a J2EE world.
Surasak Leenapongpanit
Ranch Hand

Joined: May 10, 2002
Posts: 341
Thank you, Kathy. I had the same problems like you but now I can run the first tutorial from Head first EJB.
Brian Smith
Ranch Hand

Joined: Oct 26, 2002
Posts: 232
Thanks Kathy, it works now!!
Nehul NN
Ranch Hand

Joined: Nov 05, 2003
Posts: 45
I am still having problem but error message is different. (While running AdviceClient from HJFirst ch -1 )
Lookup DONE!!!
Narrowing DONE!!!
java.rmi.AccessException: CORBA NO_PERMISSION 0 No; nested exception is:
org.omg.CORBA.NO_PERMISSION: minor code: 0 completed: No
org.omg.CORBA.NO_PERMISSION: minor code: 0 completed: No
at java.lang.Class.newInstance0(Native Method)
at java.lang.Class.newInstance(Unknown Source)
at com.sun.corba.ee.internal.iiop.messages.ReplyMessage_1_2.getSystemException(ReplyMessage_
at com.sun.corba.ee.internal.iiop.ClientResponseImpl.getSystemException(ClientResponseImpl.j
at com.sun.corba.ee.internal.POA.GenericPOAClientSC.invoke(GenericPOAClientSC.java:136)
at org.omg.CORBA.portable.ObjectImpl._invoke(Unknown Source)
at headfirst._AdviceHome_Stub.create(Unknown Source)
at AdviceClient.go(AdviceClient.java:26)
at AdviceClient.main(AdviceClient.java:13)
Any suggestion!! I am new to EJB.
Windows2000 professional Edition
J2SDK 1.3
Thank you
Paul Yen

Joined: Feb 08, 2004
Posts: 19
Thats fantastic. Thanks Kathy, I got my first EJB bean running. World is so beautiful!!

SCJP 1.4, SCWCD, SCBCD,<br />SCDJWS (preparing)
Vishwa Kumba
Ranch Hand

Joined: Aug 27, 2003
Posts: 1064
Originally posted by Paul Yen:
I got my first EJB bean running. World is so beautiful!!

With the EJBs or without the EJBs?
Just kidding
Giri Rao

Joined: Oct 23, 2004
Posts: 2
Yes!! It worked after changing the method name...Thx
Radha Shetty

Joined: May 31, 2005
Posts: 1
I had this problem and it won't go away even after changing the method name in componant interface as suggested by Kathy.

The solution is to change the security settings while creating new Enterprise bean as listed in below link. After this setting client will work even if component interface has method called getAdvice() !! I have tried it.

Shouvanik Haldar

Joined: Jun 16, 2010
Posts: 19
Hi All & Hi Kathy,

I did whatever changes you had suggested, still I am getting the following error; Below is the code

Advice.java -> Remote Interface

AdviceBean.java -> EJB

AdviceHome.java -> Remote Interface


Shouvanik Haldar
SCJP 1.5
Shouvanik Haldar

Joined: Jun 16, 2010
Posts: 19
If you hit a roadblock while running the first EJB example simply follow these steps
to run the first example of HeadFirst EJB.

1. j2sdk1.4.1 - jdk
2. j2sdkee1.3.1 - j2ee RI
3. CMD (command prompt)

Compile all the classes using c:\j2sdkee1.3.1\lib\j2ee.jar library.
Now, create a App and deploy EJB inside RI. download the application client as shown in the book.

Now, comes the tricky part.

Compile client class using the following jars

javac -classpath AdviceAppClient.jar;c:\j2sdkee1.3.1\lib\j2ee.jar AdviceClient.java

Next, run the client as follows

java -cp AdviceAppClient.jar;c:\j2sdkee1.3.1\lib\j2ee.jar;c:\j2sdk1.4.1\jre\lib\rt.jar;. AdviceClient
I agree. Here's the link: http://aspose.com/file-tools
subject: Head First EJB: 1st tut error
Similar Threads
Error running AdviceClient
Head First EJB: 1st tututial error
Error when trying the example on page 58...
HF EJB. AdviceBean example. BAD_OPERATION exception
not able to run client application