How to call an ejb from an ejb from another applicartion server  
Author Message
Andre Broers





PostPosted: 2007-11-20 2:17:00 Top

java-programmer, How to call an ejb from an ejb from another applicartion server 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
 
newbie





PostPosted: 2007-11-20 3:06:00 Top

java-programmer >> How to call an ejb from an ejb from another applicartion server 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 ;)


 
Andre Broers





PostPosted: 2007-11-20 3:55:00 Top

java-programmer >> How to call an ejb from an ejb from another applicartion server 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
 
 






PostPosted: 2007-11-20 4:57:00 Top

java-programmer >> How to call an ejb from an ejb from another applicartion server On 11/19/2007 at 14:54:31, Andre Broers <email***@***.com> wrote:

> 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.
 
 
newbie





PostPosted: 2007-11-20 5:23:00 Top

java-programmer >> How to call an ejb from an ejb from another applicartion server
Uzytkownik "Andre Broers" <email***@***.com> napisal w wiadomosci
news:email***@***.com...
> 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


 
 
Owen Jacobson





PostPosted: 2007-11-20 17:08:00 Top

java-programmer >> How to call an ejb from an ejb from another applicartion server On Nov 19, 11:54 am, Andre Broers <email***@***.com> wrote:
> 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
 
 
Andre Broers





PostPosted: 2007-11-21 17:17:00 Top

java-programmer >> How to call an ejb from an ejb from another applicartion server I do not completely understand your explaination, but I solved the
problem and blogged the sollution on my personal blog:
http://broersa.wordpress.com/2007/11/20/client-calls-ejb-on-glassfish-which-calls-ejb-on-oc4j-11g/
Maybe you know another sollution to the same problem, if you do I like
to hear it.

Mvg Andre Broers