aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Getting compile error for AdviceClient.java from Head First EJB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Getting compile error for AdviceClient.java from Head First EJB" Watch "Getting compile error for AdviceClient.java from Head First EJB" New topic
Author

Getting compile error for AdviceClient.java from Head First EJB

Raja Chandrasekaran
Greenhorn

Joined: Jun 20, 2004
Posts: 10
Hi,
I have created my first EJB Advice Guy from Head First book. I get below compile time error during AdviceClient.java compilation using -classpath options. Where AdviceClient.java is my client application to test the EJB.

All the project directories are created as per given in the Head First Book.

Please help !!

Thanks.
Raja

C:\projects\advice>javac -classpath {$CLASSPATH}:AdviceAppClient.jar AdviceClient.java
AdviceClient.java:4: package headfirst does not exist
import headfirst.*;
^
AdviceClient.java:5: package javax.ejb does not exist
import javax.ejb.*;
^
AdviceClient.java:18: cannot resolve symbol
symbol : class AdviceHome
location: class AdviceClient
AdviceHome home = (AdviceHome) PortableRemoteObject.narr
ow(o, AdviceHome.class);
^
AdviceClient.java:18: cannot resolve symbol
symbol : class AdviceHome
location: class AdviceClient
AdviceHome home = (AdviceHome) PortableRemoteObject.narr
ow(o, AdviceHome.class);
^
AdviceClient.java:18: cannot resolve symbol
symbol : class AdviceHome
location: class AdviceClient
AdviceHome home = (AdviceHome) PortableRemoteObject.narr
ow(o, AdviceHome.class);

^
AdviceClient.java:20: cannot resolve symbol
symbol : class Advice
location: class AdviceClient
Advice advisor = home.create();
^
6 errors

somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
Solution to solve this problem
1. If in Windows Platform
Please change $CLASSPATH to use %CLASSPATH%

example :

C:\projects\advice>javac -classpath %CLASSPATH%;AdviceAppClient.jar AdviceClient.java

note : and change ' : ' to ' ; '


-------- In my work ------------
I'm set classpath already before compile/run program.


SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
Raja Chandrasekaran
Greenhorn

Joined: Jun 20, 2004
Posts: 10
Yes it is in Windows platform.
Now I get "javac: invalid argument: ;" error.

How to set classpath already before compile/run program? Do I have to add the project directory path to Environment Variables? I tried that too but getting the same error.....

I am not getting why it is throwing error at
import headfirst.*;
import javax.ejb.*;

Because one of my java file with import javax.ejb.*; compiled successfully.

Please Help !! Eager to test my first EJB
nick Hussein
Greenhorn

Joined: Nov 16, 2003
Posts: 4
This is a window error only. I remember that a year ago I had this error on
windows but not on Linux. I can remember the exact solution off the top
of my head. However, it has to do with "names". Possibly, change the name
of the business method in the exmaple to another name. I am pretty sure that
it has to do with "names" of something and I am pretty sure that it only
happens on windows.

There was a long discussion on this about a year ago. I am pretty sure that
if we have the archives for a year ago, you will see a clearer answer.
Raja Chandrasekaran
Greenhorn

Joined: Jun 20, 2004
Posts: 10
nick you are very true !!

I fixed the problem. The problem was you can't have a method name that has the same characters as the interface name, this is a bug in the RI.

I changed the method name, voila! I could compile my client using the jar successfully.

Actually the problem is the version of J2EE RI, I am using older version(1.3.01) which has security bug.....anyhow I will download the latest version today.

But now when I run my client I am getting this runtime error...any idea !!

\projects\advice>java -cp %CLASSPATH%;AdvceAppClient.jar A
dviceClient
Exception in thread "main" java.lang.NoClassDefFoundError: headfirst.AdviceHome
at AdviceClient.class$(AdviceClient.java:7)
at AdviceClient.go(AdviceClient.java:18)
at AdviceClient.main(AdviceClient.java:10)

Think I am almost there.....my first EJB
Thanks
Raja
Raja Chandrasekaran
Greenhorn

Joined: Jun 20, 2004
Posts: 10
Sorry for the trouble !! It was spelling mistake....the jar file should have been AdviceAppClient.jar ...... where "i" was missing.

Thanks!! I have successfully created and test my first EJB.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting compile error for AdviceClient.java from Head First EJB