Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Access EJB from Java Application

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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.

 
I am going to test your electrical conductivity with this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic