• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

Head First EJB: 1st tut error

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
1
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
eption(ReplyMessage_1_2.java:93)
at com.sun.corba.ee.internal.iiop.ClientResponseImpl.getSystemException(
ClientResponseImpl.java:108)
at com.sun.corba.ee.internal.POA.GenericPOAClientSC.invoke(GenericPOACli
entSC.java:132)
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)
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am having the same problem. Can someone help us?
Thanks
Nick
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am having the same problem. Please do post a reply if one of you can solve the problem.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
thanks.
 
tumbleweed
Posts: 5089
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Cowgirl and Author
Posts: 1589
5
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
Whew!
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
-Kathy
 
Ranch Hand
Posts: 341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 232
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Kathy, it works now!!
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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_
1_2.java:93)
at com.sun.corba.ee.internal.iiop.ClientResponseImpl.getSystemException(ClientResponseImpl.j
ava:108)
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.
Environment:
Windows2000 professional Edition
J2SDKEE 1.3
J2SDK 1.3
Thank you
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thats fantastic. Thanks Kathy, I got my first EJB bean running. World is so beautiful!!
 
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes!! It worked after changing the method name...Thx
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

http://sunsolve.sun.com/search/document.do?assetkey=1-30-00665-1
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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



AdviceClient.java








 
Shouvanik Haldar
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you hit a roadblock while running the first EJB example simply follow these steps
to run the first example of HeadFirst EJB.

Softwares
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
 
The harder you work, the luckier you get. This tiny ad brings luck - just not good luck or bad luck.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic