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

Discussion in 'Java' started by Andre Broers, Nov 19, 2007.

  1. Andre Broers

    Andre Broers Guest

    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
     
    Andre Broers, Nov 19, 2007
    #1
    1. Advertising

  2. Andre Broers

    newbie Guest

    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 ;)
     
    newbie, Nov 19, 2007
    #2
    1. Advertising

  3. Andre Broers

    Andre Broers Guest

    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
     
    Andre Broers, Nov 19, 2007
    #3
  4. Andre Broers

    derek Guest

    On 11/19/2007 at 14:54:31, Andre Broers <> 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.
     
    derek, Nov 19, 2007
    #4
  5. Andre Broers

    newbie Guest

    Uzytkownik "Andre Broers" <> napisal w wiadomosci
    news:...
    > 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
     
    newbie, Nov 19, 2007
    #5
  6. On Nov 19, 11:54 am, Andre Broers <> 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
     
    Owen Jacobson, Nov 20, 2007
    #6
  7. Andre Broers

    Andre Broers Guest

    Andre Broers, Nov 21, 2007
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve
    Replies:
    1
    Views:
    732
    John C. Bollinger
    Jul 15, 2003
  2. Mumbai Joe
    Replies:
    0
    Views:
    632
    Mumbai Joe
    Jul 29, 2003
  3. Jeremy Haile

    To EJB or not to EJB

    Jeremy Haile, Sep 3, 2003, in forum: Java
    Replies:
    5
    Views:
    560
    Christopher Blunck
    Sep 10, 2003
  4. Rizwan
    Replies:
    2
    Views:
    4,370
    Rizwan
    May 3, 2005
  5. Raymond Schanks
    Replies:
    0
    Views:
    702
    Raymond Schanks
    Aug 3, 2010
Loading...

Share This Page