Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Andre Broers - 19 Nov 2007 18:16 GMT
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 - 19 Nov 2007 19:06 GMT
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 - 19 Nov 2007 19:54 GMT
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
derek - 19 Nov 2007 20:57 GMT
> 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
[quoted text clipped - 5 lines]
> 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 - 19 Nov 2007 21:23 GMT
> 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
[quoted text clipped - 4 lines]
> 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 - 20 Nov 2007 09:07 GMT
> 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
[quoted text clipped - 4 lines]
> 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 - 21 Nov 2007 09:17 GMT
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-call
s-ejb-on-oc4j-11g/

Maybe you know another sollution to the same problem, if you do I like
to hear it.

Mvg Andre Broers


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.