Did a little more research...
If i put the code that I used to put in a Servlet inside a normal Java file and execute it ... Everything works properly. So it seems that in order for LoadBalancing to work properly we need to execute the calls from a separate JVM. Is that correct?
Can anyone please confirm it?
Also is there any way to move past this restriction?
OK! Finally found a solution to my problem :)
JBoss 'all' domain comes with certain AOP interceptors for EJB3. Of these the IsLocalInterceptor and ClusteredIsLocalInterceptor were creating all this fuss. I just disabled them and everything works fine.
You'vre done well on your hunt. :-)
Be aware, though, that you might have problems if you have a transaction running and you make an EJB call that ends up going to the in-VM bean. The TxPropagationInterceptor will not handle this well if the (Clustered)IsLocalInterceptor is bypassed. See http://jira.jboss.com/jira/browse/EJBTHREE-1005.
This will only be a problem for you if your servlet initiates transactions or your beans make calls from one to another within a tx.
I'm trying to do the exact same thing and I also noticed that the round robin works if the client code is executed from another jvm. I see your solution is to disable IsLocalInterceptor and ClusteredIsLocalInterceptor in the ejb3-interceptors-aop.xml file. I see in the DTD that the interceptor scope can be PER_VM|PER_CLASS|PER_INSTANCE|PER_JOINPOINT|PER_CLASS_JOINPOINT and the default is PER_VM. What value should I change it to or what do you mean by disabling IsLocalInterceptor and ClusteredIsLocalInterceptor?
I must say that I'm a bit puzzled that this is something that you must configure in an (obscure) config file in order to get it to work. And perhaps even more that you cannot find anything about it in the documentation.
Is it an uncommon scenario that you want to have a process that runs on one node in a cluster and then spreads the load on all nodes via a clustered slsb that typically uses round robin? At least I didn?t think so before I tried it.
Anyways, I found the place in the ejb3-interceptors-aop.xml file (I think) and got it working
<stack name="StatelessSessionClientInterceptors"> <!--<interceptor-ref name="org.jboss.ejb3.remoting.IsLocalInterceptor"/>--> <interceptor-ref name="org.jboss.aspects.security.SecurityClientInterceptor"/> <interceptor-ref name="org.jboss.aspects.tx.ClientTxPropagationInterceptor"/> <interceptor-ref name="org.jboss.aspects.remoting.InvokeRemoteInterceptor"/> </stack>
<stack name="ClusteredStatelessSessionClientInterceptors"> <!--<interceptor-ref name="org.jboss.ejb3.remoting.ClusteredIsLocalInterceptor"/>--> <interceptor-ref name="org.jboss.aspects.security.SecurityClientInterceptor"/> <interceptor-ref name="org.jboss.aspects.tx.ClientTxPropagationInterceptor"/> <interceptor-ref name="org.jboss.aspects.remoting.ClusterChooserInterceptor"/> <interceptor-ref name="org.jboss.aspects.remoting.InvokeRemoteInterceptor"/> </stack>