Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Communication between EJBs deployed in different Application Servers from different vendors

 
Lekamge Perera
Greenhorn
Posts: 5
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All

I ‘m trying to create a small EJB 3.1 application in which I want to use two application servers from two different vendors. (JBoss 6.1.0 Final and Glassfish 3.1). This is just to experience the taste of distributed applications and new features of EJB3.1.

This is the problem I’m having…

I have created a simple EJB (kind of a hello world ejb) and deployed it in GlassFish server which is running in machine A. Let’s call it GlassFishHelloWorldEjb. This one has business remote and local views.
I have created another EJB project in which I have an EJB called JBossHelloWorldEjb. I have deployed it in the Jboss server which is running in the machine B.

Now I want to inject GlassFishHelloWorldEjb to a reference in the JBossHelloWorldEjb so that I can call it within the JBossHelloWorldEjb. Then I have a web app deployed in the Jboss which calls the JBossHelloWorldEjb.

MyWebApp(Jboss, machine B)-----> JBossHelloWorldEjb (Jboss, machine B)----> GlassFishHelloWorldEjb(GlassFish, Machine A)

I tried many ways to inject the GlassFishHelloWorldEjb in to the JBossHelloWorldEjb but failed. Could some please shed some light to achieve this.

Would greatly appreciate if you could show me the way to do this through both INJECTION and Programmatic JNDI look up.

Cheers
Asanka
 
Lekamge Perera
Greenhorn
Posts: 5
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please?
 
Andrew Moko
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I havent tried writing a distributed app running on diff application servers however here's my two cents. Have GlassFishHelloWorldEjb registered on the glassfish jndi tree and assign a remote jndi name. Do the same with JBossHelloWorldEjb have it registered under jboss. On JBossHelloWorldEjb, have a copy reference of GlassFishHellWorldEjb with all associated/ related objects/ depencencies. Then do a context lookup using the remote glassfishejb jndi name and map it onto the reference object.

Something like:
Context ctx = new InitialContext(env);
GlassFishHelloWorldEjb bean = (GlassFishHelloWorldEjb) PortableRemoteObject.narrow(ctx.lookup("jndi.glassfishhelloworld"), GlassFishHelloWorldEjb.class);

Not sure how to go about injecting a remote bean but a jndi lookup always works just fine.

Good luck!
 
Mr sujeet khandelwal
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

One more solution to solve this problem you can make "GlassFishHelloWorldEjb" to webservice.

It would require you to do
- @WebService annotation to "GlassFishHelloWorldEjb".
- Create a client of "GlassFishHelloWorldEjb" in app of jboss.
- Use that client in "JbossHelloWorldEjb".

cheers.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic