Meaningless Drivel is fun!*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Can't run the Client program - of HFE -- HELP -- Urgent Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Can Watch "Can New topic
Author

Can't run the Client program - of HFE -- HELP -- Urgent

paromitabanerjee mukerjibanerjee
Greenhorn

Joined: Dec 20, 2004
Posts: 23
Hi,

I am following the HFE. And created the classes in the first chapter. All the steps worked fine and got deployed.

But while compiling the Client -- it gives 6 errors :
1) package headfirst.*; -- doesn't exist
2) package javax.ejb.*;
3) Cannot resolve symbol AdviceHome (3 places)
4) Cannot resolve symbol Advice.

The code for the client is :
import javax.naming.*;
import java.rmi.*;
import javax.rmi.*;
import headfirst.*;
import javax.ejb.*;

public class AdviceClient
{
public static void main(String[] args)
{
new AdviceClient().go();
}
public void go()
{
try{
Context ic = new InitialContext();
Object o = ic.lookup("Advisor");

AdviceHome home = (AdviceHome) PortableRemoteObject.narrow(o, AdviceHome.class);

Advice advisor = home.create();
System.out.println(advisor.getAdvice());
}catch(Exception ex)
{
ex.printStackTrace();
}
}
}


Can any one please help !!!

My env variables are :-
1) CLASSPATH : C:\jdk1.3.1_19\lib;C:\j2sdkee1.3.1\lib;C:\j2sdkee1.3.1\lib\j2ee.jar;.;
2) J2EE_HOME : C:\j2sdkee1.3.1;
3) JAVA_HOME : C:\jdk1.3.1_19;
4) PATH : C:\jdk1.3.1_19\bin;C:\j2sdkee1.3.1\bin;

what is going wrong here ???
Tanakorn Numrubporn
Ranch Hand

Joined: Dec 11, 2006
Posts: 81
I want to see your command that you type in dos.
I will assume that you organize you client files similar to the book said.

So your AdviceAppClient.jar and AdviceClient.class is stay under ~projects/advice.

Your problem is maybe relate to classpath on running process.
When you run this client program you must gather both AdviceAppClient.jar and j2ee.jar in your command. So the command for run this program is :

C:\projects\advice>java -cp .;AdviceAppClient.jar;%classpath%;j2ee.jar AdviceClient

I see your classpath setting already has j2ee.jar. So you can change from %classpath%;j2ee.jar to %classpath% in this command.

PS. I think it best to take '.;' stay at the front of every classpath in classpath environment. Because order in classpath does matter. And if your take my advice you may no need to type .;AdviceAppclient.jar in you command.
paromitabanerjee mukerjibanerjee
Greenhorn

Joined: Dec 20, 2004
Posts: 23
Hey Tanakorn,

It worked gt8 ....

Problem was with the command line argument I was writing...

thanks a lot for your help.

regards,
Paromita
SCJP
SCWCD
MCP
paromitabanerjee mukerjibanerjee
Greenhorn

Joined: Dec 20, 2004
Posts: 23
Okay... spoke too soon :roll:

I was not able to compile the client class.. which is working fine now

but I am unable to run the Cleint.

Its giving the following error :
Exception in thread main "java.lang.NoClassDefFoundError".

but my client class has a main method!! Pls see the code above.
the command line I am writing is :

C:\j2sdkee1.3.1\projects\advice>java -cp AdviceAppClient.jar;%classpath%; AdviceClient

Any help ??? pls
Tanakorn Numrubporn
Ranch Hand

Joined: Dec 11, 2006
Posts: 81
Originally posted by paromitabanerjee mukerjibanerjee:
Okay... spoke too soon :roll:

I was not able to compile the client class.. which is working fine now

but I am unable to run the Cleint.

Its giving the following error :
Exception in thread main "java.lang.NoClassDefFoundError".

but my client class has a main method!! Pls see the code above.
the command line I am writing is :

C:\j2sdkee1.3.1\projects\advice>java -cp AdviceAppClient.jar;%classpath%; AdviceClient

Any help ??? pls



It is the same problem. If you be careful the -cp argument that you give is wrong format. You should type:

C:\j2sdkee1.3.1\projects\advice>java -cp .;AdviceAppClient.jar;%classpath% AdviceClient

so I repair you command line for two points.
first: add '.;' in front of AdviceAppClient.jar.
second: delete ';' behind %classpath%.

good luck and joy with the subject.
paromitabanerjee mukerjibanerjee
Greenhorn

Joined: Dec 20, 2004
Posts: 23
I put in the above command -- but it still gives the same error....
Tanakorn Numrubporn
Ranch Hand

Joined: Dec 11, 2006
Posts: 81
And try to move you '.;' in your classpath setting to most front (I see you set to the most behind). Now you can try to type:
~projects\advice>java -cp %classpath% AdviceClient

It look short and not error prone
paromitabanerjee mukerjibanerjee
Greenhorn

Joined: Dec 20, 2004
Posts: 23
gives the same error
paromitabanerjee mukerjibanerjee
Greenhorn

Joined: Dec 20, 2004
Posts: 23
do I have to mention

package headfirst;

in my AdviceClient.java

Its not mentioned in the book but just wondering ???

This is urgent..... any help plssssss !!!
Tanakorn Numrubporn
Ranch Hand

Joined: Dec 11, 2006
Posts: 81
If your AdviceAppClient.jar and AdviceClient.class in stay under ~projects\advice. This is not a problem.

I have two others solution.
First: Let go to the
Start>Control Panel>System>Environment variables.
In Environment variables window click "new" button for User variables for Admin.
In the variable name type whatever you want such as ADVICE_HOME blah blah blah.

For variable value type:

.;C:\JavaProjects\projects\advice\AdviceAppClient.jar;C:\j2sdkee1.3.1\lib\j2ee.jar

(The path for AdviceAppClient.jar and j2ee.jar is depend on you.)

NOW you try to type for command like this:
C:\javaProjects\projects\advice>java -cp %ADVICE_HOME% AdviceClient

Second:solution
copy j2ee.jar from C:\j2sdkee1.3.1\lib\ and paste it to the path that contains AdviceAppClient.jar and Advice.class and now you can type

C:\javaProjects\projects\advice>java -cp .;AdviceAppClient.jar;.;j2ee.jar AdviceClient
Chidu Chidambaram
Greenhorn

Joined: Sep 18, 2003
Posts: 7
check out a post by kathy sierra...right when this book came out...there are step by step instructions to resolve the issue
Chidu Chidambaram
Greenhorn

Joined: Sep 18, 2003
Posts: 7
This is the text of the post from the original one in Nov 2003

Howdy -- I thought I'd start a new topic on this rather than add to the old one.
Some people have been getting this incredibly helpful and enlightening CORBA.BAD_OPERATION error when they run the AdviceClient client on the J2EE 1.3 RI, at the point where the business method (getAdvice()) is invoked:


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(Class.java:232)
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(ObjectImpl.java:454)
at headfirst._Advice_Stub.getAdvice(Unknown Source)
at AdviceClient.go(AdviceClient.java:27)
at AdviceClient.main(AdviceClient.java:9)

========================

But not everyone gets it. Me, for example. But thanks to Chidu, I know for certain that this is some type of bug and not a programmer error, because Chidu sent me his entire project and I was able to run it perfectly on my machine. Yet, running the same application and class files (I even deployed his existing .ear file - I didn't recreate one using his classes) he DOES get the error. I have verified that he has done everything correctly, yet on his machine he still gets the error.

It cannot be a classpath problem, because if it were, it would fail at an earlier point.

I have a reason to suspect that this is related to a known bug in the RI, but since I am unable to reproduce the error (because it always works for me), I'm asking if someone who has this error could try the fix I'm going to give you in a moment.

Some of you HAVE been able to fix it with a terrible workaround (where you take the classes out of a package!) but we don't want you to have to do that! You could never get away with that in the real world, so we want you to keep the classes in packages.

Here's my suspicion that I would REALLY appreciate if someone could test it. Either someone who is currently getting the error, or someone who did before, and who fixed it by removing the packages (in which case, you'd have to put everything BACK into a package...)

The RI has a known bug that *might* be the problem. It has to do with the name of a method in an component interface, when it is somehow related to the interface name itself.

I think you should change the name of the method, and rebuild and redeploy the bean. If this fixes it, we will post a note on our site and O'Reilly, letting people know that they *might* have that bug.

By the way, if you run "j2ee -version" at the command-line, you'll find out which one you're using. I'm using:

Java 2 Enterprise Edition version 1.3.1, build 1.3.1-b17

And I do not get this error, even when running an application that produces this error on a different machine. I am running the Linux distribution, under Mac OSX (works under Jaguar and the new Panther), with J2SE 1.3.

So, here's the fix I want someone to try, and if it works, you will certainly be the hero.

1) Undeploy your current AdviceApp by cleaning up the server
-- stop J2EE "j2ee -stop"
-- run "cleanup" at the command-line

2) Delete your application from your projects/Advice directory (in other words, delete the .ear file), and if there are any .temp files, delete those as well.

3) Change your component interface and name the method something that does NOT have "Advice" in the name... so, instead of getAdvice(), call it getSomething()...

4) Change your bean class business method to match the business method name in the interface

5) Recompile

-- restart the server and the deploytool

6) Rebuild the bean from scratch (first build a new application, then New --> Enterprise Bean

7) Deploy the bean

8) Modify the client code to call the new method (instead of the getAdvice() method)

9) Invoke the appropriate diety / spirit / good luck charm

10) Run the client (might help to hold your breath until it's done)

Post your wonderful success story here, so I can sleep again.

So, once again, somebody who had this error PLEASE help by trying this fix. There's a good chance this is the problem.

thanks,
Kathy
Gowher Naik
Ranch Hand

Joined: Feb 07, 2005
Posts: 643
Hi Chidu
i followed your steps and it really worked.
Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can't run the Client program - of HFE -- HELP -- Urgent
 
Similar Threads
head first ejb pg:57 client problem!!!please help urgent
help!: AdviceClient.java does not compile
Error compiling the AdviceClient.java
how to run a client?
HFEJB AdviceClient.java Compilation Error