Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using swing as a client for an EJB, help

stewart ridgway
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi im in need of some help with a J2EE application im working on. I need to develop a JFrame front-end GUI client that will talk to the server, however i am not sure how to use JFrame to invoke methods on the server. This is mainly because im struggling to understand how I can call a method on the client side that will call a method on the server side when it appears to me that the client doesn't have a handle on the server-side (If that makes sense?)

I have crawled the web for some examples(including sun) but I still cannot find a tutorial.

I think my biggest problem is where I access the bean and how I can use it to set the JLabel to "hello World"
So I created a simple 'Tester' package that had a stateless session bean with one method which was to return a String. When the client GUI clicked a JButton its JLabel updated to the value. I initially created all of the code without a JFrame and compiled it using ant, and it worked fine (printing to the console).

Then I added some JFrame code to the frontend, but I got 28 error messages when I did so. My real questions are how to call methods on the bean and where I do this, take a look at the 'actionPerformed' method I call on the beans method here but it causes an error, also Im stuck as to where I must place the IntitialContext and EJB creation/casting/JNDI lookup stuff in the class.

I can write all the server-side/business methods its just the GUI im getting stuck on(this is just a testing example).

The following is the TesterBean and TesterClient files
I have done a printscreen on the errors, they can be found
here here

[ March 12, 2006: Message edited by: stewart ridgway ]
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic