0

I have a Java EE server that calls a bean in project A from a Servlet in project B. Both projects are in the same "cell" (cluster). I would like to go through a load balancer as well. I do not want to use Message Driven Beans or Web Services.

Is there any other way to do this, and how can would that be implemented?

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
otc
  • 694
  • 1
  • 9
  • 40
  • There are two servers in this cell (cluster) for redundancy containig a copy of each project and the load balancer switches between the two. So if a call comes from project A of server 1 i want to go possibly to project B server 1 or server 2 depending on availability – otc Jul 12 '12 at 19:15
  • Also the projects do not currently have dependency on each other – otc Jul 12 '12 at 19:27

2 Answers2

1

Actually after some time I found the solution:

Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming
.WsnInitialContextFactory");
env.put(Context.PROVIDER_URL,"corbaloc::boris:9811,:natasha
:9812");
Context ctx = new InitialContext(env);
TestEJBHome home = (TestEJBHome)
PortableRemoteObject.narrow(ctx.lookup("ejb/ejbs/TestEJBHome"),
    TestEJBHome.class);
TestEJB bean = home.create();

Got it from here: http://www.ibm.com/developerworks/websphere/techjournal/0807_pape/0807_pape.html

otc
  • 694
  • 1
  • 9
  • 40
0

If the application containing the EJB is deployed on the same cluster as the client, then WebSphere will always route the request to the EJB in the same application server as the client, and the call will be an in-VM call (instead of an out-of-process call). This is called process affinity. As far as I know there is no way to avoid or disable process affinity.

Andreas Veithen
  • 8,868
  • 3
  • 25
  • 28