Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Found solution to AdviceClient...Ha Ha

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello guys.
If you have an environment like mine and you were stuck for days
with trying to run the client......... i found the solution!
Windows XP
1.3.1 jdk2ee
j2sdk 1.4.2_03
The solution has to do with how you configure the CLASSPATH and what is the command to compile and run the client.
The source is as in the HF EJB book but instead of getAvice() i use getMessage() which i do not know if it helps!( I will test it with getAdvice() later) I also have added some comments for debugging purposes. Take a look:
-----------------------------CODE-----------------------------------------
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();
System.out.println("Context Created!!!");
Object o = ic.lookup("Advisor");
System.out.println("Lookup DONE!!!");
AdviceHome home = (AdviceHome)PortableRemoteObject.narrow(o, AdviceHome.class);
System.out.println("Narrowing DONE!!!");
Advice advisor = home.create();
System.out.println("Remote Object Created!!!");
System.out.println(advisor.getMessage());
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}
----------------------------------------------------------------------------
---------------------SOLUTION-----------------------------------------------
1)Your CLASSPATH environmental variable should include the path to j2ee.jar and also to the advice directory like this:
C:\j2sdkee1.3.1\lib\j2ee.jar;C:\source\projects\advice
2)To compile the client you type the following from advice directory:
javac -classpath %CLASSPATH%;%CLASSPATH%\AdviceAppClient.jar AdviceClient.java
3)To run the client you type the following from advice directory:
java -classpath %CLASSPATH%;%CLASSPATH%;\AdviceAppClient.jar AdviceClient
That's all folks. I hope that will help you.
Ooh i can't stop running the client.....everytime a different message is displayed............he he
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are using the RI, this bug will cause problems with the "getAdvice()" method
http://www.wickedlysmart.com/HeadFirst/HeadFirstEJB/HeadFirstEJBNotes.html
 
Loukas G
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oh and not to forget...if you have any program running like Norton Internet Security you should disable it because it prevents the client to run and a bunch of exceptions appear from nowhere
 
Loukas G
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok......... there is an error in the command to run the client. Instead of :
java -classpath %CLASSPATH%;%CLASSPATH%;\AdviceAppClient.jar AdviceClient
USE THIS :
java -classpath %CLASSPATH%;%CLASSPATH%\AdviceAppClient.jar AdviceClient
 
reply
    Bookmark Topic Watch Topic
  • New Topic