Session Bean To Session Bean Invocation
foutjo Mar 30, 2012 10:28 AMCan anyone tell me how I would get setup a session bean to get access to another session bean from either the same server or another clusterd server?
I have read lots of confusing threads on how this might be done but I can't seem to find a clear answer.
Here is a my scenario:
SLSB#1 (Not Clustered) Deployed on Server#1
SLSB#2 (Clustered) Deployed on Server#1/Server#2/Server#3
Java Client Server #1 Server #2 Server #3
--------------- -------------- ------------- -------------
SLSB#1 SLSB#2 SLSB#2
SLSB#2
1. The java client can successfully get access to SLSB#1 using the following code along with the jboss-ejb-client.properties file:
final Hashtable<String, String> jndiProperties = new Hashtable<String, String>();
jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
final Context context = new InitialContext(jndiProperties);
final String appName = "";
final String moduleName = "Server-Listener-EJB";
final String distinctName = "";
final String beanName = "Server_Listener";
final String viewClassName = Server_ListenerINF.class.getName();
String bean = "ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName
+ "!" + viewClassName;
Server_ListenerINF serverListener = (Server_ListenerINF) context.lookup(bean);
adminReturned = serverListener.processAdminTran(adminObject);
2. Now I want to have SLSB#1 get access to SLSB#2.
Being that SLSB#2 is clustered here was the java code used to
successfully access SLSB#2 using JBOSS 5.1.
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
p.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
String partitionName = System.getProperty("jboss.partition.name", "clusterPartition2");
p.put("jnp.partitionName", partitionName);
try
{
ctx = new InitialContext(p);
String s = "Background" + process.getBackgroundType() + "SessionBean/remote";
BackgroundTranSessionRemoteINF bean = (BackgroundTranSessionRemoteINF) ctx.lookup(s);
bean.process(backgroundData);
}
.....
QUESTION: How do accomplish the above using JBOSS-AS-7?
I have read jaikiran pai document : EJB invocations from a remote server instance
But I am still confused. Not sure if this is what I should be doing or is there another way.
I have be trying to resolve this issue since JBoss 7.0 was released.
It took be a very long time to finally figure out how to get it to work in JBoss 5.1 and
now I'm right back where I started from in JBoss 7. Very frustrating:(
Any help on this topic by the resident JBOSS Experts is greatly appreciated.
Thanks.