简体   繁体   中英

Call bean of project A from servlet of project B

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?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM