Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to connect between EJB and anothe EJB in another JVM ???

 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now, I don't know , how to connect/lookup between EJB in one JVM and EJB in another JVM ...


help me please ...
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EJB in machine A can use JNDI to lookup the remote component or home interface for the EJB in machine B, creating it (if necessary), and then use the EJBObject to get the services from EJB in machine B.

Nick
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



Value for Context.INITIAL_CONTEXT_FACTORY depends on the app server. Context.PROVIDER_URL is the server URL.
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course, EJB in machine B must register its services and JNDI name to the JNDI registry. Or, there maybe a Service Locator that knows which locations that the EJB located.

Nick
 
Alexandru Popescu
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean connect between EJB in one machine and EJB in other machine?
Is it about a cluster? Or is it only 2 applications communication?
If the 1st is true: you declare ejb-ref and than you perform the normal lookup (and is not important where exactly the container is running)
If 2nd is true: your EJB wanting connection will need to do the same steps as a regular client.
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If 2nd is true: your EJB wanting connection will need to do the same steps as a regular client


yes, but dont forget to pass the URL of the 2nd machice to the InitialContext.
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much for all answer.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic