• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

question about the 1st example in HF EJB

 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first example in HF EJB (AdviceBean, Advice, AdviceHome) ---

I run the code and deployed it to the RI server following Kathy's instruction (pg 29 -- pg 57). Here are my 2 basic questions ---

1. In order to run the Client, we need to add the "AdviceAppClient.jar" in the classpath. However, as I know, the client can be any standalone java application residing on any machine. If we always require the client side to include this server generated JAR file, it is impossible. So, I am wondering how it should work for a standalone client ?

2. I opened one console window, everytime I type "java -cp ... AdviceClient"
it always returns me with the same advice message. I don't know why ? It seems the AdviceBean is supposed to use a random number to pick an advice, why do I always get the same random number on this console window ?
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. "Client" is a loose term here. The code interacting with the stubs will still usually be on the server. For instance, in web applications (http/html), the client isn't directly calling any java methods. All the client does is submit and get html forms. In any multi-tiered architecture, the real client doesn't even know that the backend is using EJBs at all, nor does it care.

2. This reminds me of dealing with pseudorandom numbers in VB. I had to use the current time to offset the number. I think the Java api's Math.random and Random do this for you, so it surprises me that you are getting the same one each time. Maybe Advice Guy is trying to tell you something!
 
Something must be done about this. Let's start by reading this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic