• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting compile error for AdviceClient.java from Head First EJB

 
Raja Chandrasekaran
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1312
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Raja Chandrasekaran
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic