• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Access EJB from Java Application

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi.........

I have a EJB 3 application which is deployed on JBoss server.

I have develop a java application which access the EJB. It works fine when both application on same machine.

My problem is I want to place EJB @ centralized location and client @ remote places.

If any changes happen to EJB it should not required to rebuild the jar @ every places.

I am calling EJB like this



When I put it on different machine It will not get MyBeanRemote class cause it is not @ every client machine

Please suggest something

I want to extend this application to SWING and calling EJB from Swing app. so that GUI is @ client side and Business Logic is @ server.


Thanks
 
Ranch Hand
Posts: 174
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>>My problem is I want to place EJB @ centralized location and client @ remote places.

This is one of the problem that EJB tries to solve.

MyBeanRemote should be an interface.. and it must be available at the client in the remote machines.

 
shashi wagh
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Following are the Steps which I have performed

1 Created EJB 3 application in Myeclipse
2 Deployed it on JBoss 4.2
3 Created a Java Application in MyEclipse
4 Configure the build path to access the EJB application
5 Start the Server
6 Run the Application in MyEclipse.
7 It Works Fine.


Now I export the Client application to Jar --------> TestClient.jar
Now I export the Interfaces in EJB application to --------> TestBeanInterface.jar

Following is the command I used to run the Client
java -cp "TestBeanInterface.jar;jbossall-client.jar";TestClient.jar com.gts.ejbdemo.client.MyBeanClient

N got the following output



Tell me what is I am doing wrong.........

But when I export all ejb application to jar It works................

Edited by: shashiwagh on Feb 26, 2010 4:53 AM
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Now I export the Client application to Jar --------> TestClient.jar
Now I export the Interfaces in EJB application to --------> TestBeanInterface.jar

Following is the command I used to run the Client
java -cp "TestBeanInterface.jar;jbossall-client.jar";TestClient.jar com.gts.ejbdemo.client.MyBeanClient



Simply using a java client and including the ejb jar is not enough...

There are two possibilities to call EJBs from a remote client, which is not deployed at the application server:
1) Use an application client (JEE implementations offer an ejb container, web container and application client container - the latter one is for using jee features such as dependency injection from a J2SE client)
2) Get the ejb via JNDI lookup. you have to configure the server url, port and so on.

reply
    Bookmark Topic Watch Topic
  • New Topic