How to call an ejb from an ejb from another applicartion server

A

Andre Broers

What is the preferred way to call an ejb on another application server
from an ejb? Someone give me a clue? The only sollution I see in
google are in the same application server.

Mvg Andre Broers
 
N

newbie

You mean like another type of application server or just the same type of
application server on other machine?
Cause if it's the second, that's the whole idea of remote interfaces ;)
 
A

Andre Broers

Doesn't matter.. The problem I face is the following:
When I try to call an ejb on another server I don't think it will work
with the @EJB annotation. The way I think I have to do it is the
Initial Context of the server to be called to get the Bean(Proxy)
instance. This works when I hardcode the properties to get the Initial
Context in the EJB. What I'm searching for is the preferred way to do
it dynamic. Maybe an ejb reference but I see only examples calling an
ejb in the same jvm.

Mvg Andre
 
D

derek

Doesn't matter.. The problem I face is the following:
When I try to call an ejb on another server I don't think it will work
with the @EJB annotation. The way I think I have to do it is the
Initial Context of the server to be called to get the Bean(Proxy)
instance. This works when I hardcode the properties to get the Initial
Context in the EJB. What I'm searching for is the preferred way to do
it dynamic. Maybe an ejb reference but I see only examples calling an
ejb in the same jvm.
Mvg Andre

I asked a speaker at javaone this same question. His response was to use web services.
Seemed to me also there should be a more elegant(SIMPLE) solution to this.
 
N

newbie

Uzytkownik "Andre Broers said:
Doesn't matter.. The problem I face is the following:
When I try to call an ejb on another server I don't think it will work
with the @EJB annotation. The way I think I have to do it is the
Initial Context of the server to be called to get the Bean(Proxy)
instance. This works when I hardcode the properties to get the Initial
Context in the EJB. What I'm searching for is the preferred way to do
it dynamic. Maybe an ejb reference but I see only examples calling an
ejb in the same jvm.

First of all, it kinda matters ;)
When you invoke EJBs on another type of application server, most of the time
you've got to use a kind of bridge. In my work we use applications on JBoss
2.4.7 and JBoss 3.2.1. Believe me, you can't just invoke method from the
EJB. You've got to configure a bridge between them. I won't give you details
here simply because I don't remember them, but it's not that easy.
Any about the dynamic thing ... Make it dynamic on the application level.
Create a table in your database that contains the properties and select from
it every time you want to connect to ejb deployed on the other server. This
way you won't have to build your application every time the address changes.

Regards
 
O

Owen Jacobson

Doesn't matter.. The problem I face is the following:
When I try to call an ejb on another server I don't think it will work
with the @EJB annotation. The way I think I have to do it is the
Initial Context of the server to be called to get the Bean(Proxy)
instance. This works when I hardcode the properties to get the Initial
Context in the EJB. What I'm searching for is the preferred way to do
it dynamic. Maybe an ejb reference but I see only examples calling an
ejb in the same jvm.

The automatic dependency discovery relies on JNDI. It's not magic.
However, to get a remote app server's beans in the right places will
probably require some vendor-specific configuration info.

Let's say you have a session bean named com.example.HelloWorld with a
method
@EJB
public void setMessageProvider (MessageProvider provider) {...}
through which a second EJB (implementing MessageProvider) is
injected. When the container goes to populate the properties of the
HelloWorld bean, it looks up the following JNDI name:

java:comp/env/com.example.HelloWorld/messageProvider

and, if it finds an object there that implements MessageProvider, it
injects it.

There is a little bit of extra magic involved when there is a
MessageProvider-implementing bean in the same application: the app
server is required to automatically map it to that name because its
interface matches the required interface of the injection target. You
can do a lookup for that name in your code yourself and find the
MessageProvider there, if your server follows the rules, even if you
never explicitly told anything to put it there.

Nothing about injection *requires* that the MessageProvider object at
that name be from the local container, though. Using container-
specific configuration you can put any object you like under that name
in the right namespace, at which point injection will pick it up and
use it.

The real problem is mapping an external server's EJBs into the
java:comp/env/ namespace of the right EJB on the local server. Since
you haven't specified which server(s) are involved, I can't offer you
anything concrete beyond "check the docs" and look up "remote jndi" or
"federated jndi" to see if there are any clues there.

-Owen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top