"call by reference" between ejbs inside the same ear and "
pako May 18, 2006 11:43 AMI want to make jndi lookup across ears that are isolated.
I have made the following tests:
1) I have configured all ears to be in isolated classloader spaces.
file deploy/ear-deployer.xml :
<!-- A flag indicating if ear deployments should have their own scoped
class loader to isolate their classes from other deployments.
-->
true
<!-- A flag indicating if the ear components should have in VM call
optimization disabled.
-->
false
I have deployed two ear , earA and earB ; the earA contains the ejbA and earB contains ejbB.
The ejbA calls the ejbB in this way :
Properties env =new Properties();
env.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
env.setProperty(Context.PROVIDER_URL,"jnp://cst001.csi.it:1100");
InitialContext ic = new InitialContext(env);
Object objRef = ic.lookup(jndiMyStatless);
home = (MyStatlessHome)PortableRemoteObject.narrow(objRef, MyStatlessHome.class);
MyStatless clientStatless = (MyStatless)home.create();
and I obtain the exception :
2006-05-18 16:20:52,382 ERROR [org.jboss.ejb.plugins.LogInterceptor] TransactionRolledbackException in method:
public abstract it.csi.oss.clusterejb.interfaces.MyStatless it.csi.oss.clusterejb.interfaces.MyStatlessHome.create
() throws javax.ejb.CreateException,java.rmi.RemoteException, causedBy:
javax.ejb.EJBException: Invalid invocation, check your deployment packaging, method=public abstract
it.csi.oss.clusterejb.interfaces.MyStatless it.csi.oss.clusterejb.interfaces.MyStatlessHome.create() throws
javax.ejb.CreateException,java.rmi.RemoteException
at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invokeHome
(StatelessSessionContainer.java:161)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome
(CachedConnectionInterceptor.java:212)
at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invokeHome
(StatelessSessionInstanceInterceptor.java:81)
at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:90)
at org.jboss.ejb.plugins.CallValidationInterceptor.invokeHome(CallValidationInterceptor.java:41)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:109)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:335)
at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:146)
at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:116)
at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:121)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:93)
at org.jboss.ejb.SessionContainer.internalInvokeHome(SessionContainer.java:613)
at org.jboss.ejb.Container.invoke(Container.java:894)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
at org.jboss.invocation.local.LocalInvoker$MBeanServerAction.invoke(LocalInvoker.java:155)
at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:104)
...
...
2) I have configured all ears to be in isolated classloader spaces using call by value for remote interface.
file deploy/ear-deployer.xml :
<!-- A flag indicating if ear deployments should have their own scoped
class loader to isolate their classes from other deployments.
-->
true
<!-- A flag indicating if the ear components should have in VM call
optimization disabled.
-->
true
I have deployed two ear , earA and earB ; the earA contains the ejbA and earB contains ejbB.
the ejbA calls the ejbB in the same way of point 1) :
Properties env =new Properties();
env.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
env.setProperty(Context.PROVIDER_URL,"jnp://cst001.csi.it:1100");
InitialContext ic = new InitialContext(env);
Object objRef = ic.lookup(jndiMyStatless);
home = (MyStatlessHome)PortableRemoteObject.narrow(objRef, MyStatlessHome.class);
MyStatless clientStatless = (MyStatless)home.create();
in this way all works, but unfortunately also the calls between ejb inside the earA are made by value
and this is very inefficent.
3) I have configured all ears to be in isolated classloader spaces using call by value for remote interface.
file deploy/ear-deployer.xml :
<!-- A flag indicating if ear deployments should have their own scoped
class loader to isolate their classes from other deployments.
-->
true
<!-- A flag indicating if the ear components should have in VM call
optimization disabled.
-->
true
I have deployed two ear , earA and earB ; the earA contains the ejbA and earB contains ejbB.
the ejbA calls the ejbB in the same way :
Context initCtx = new InitialContext();
Context ejbCtx = (Context)initCtx.lookup("java:comp/env/ejb");
Object objRef = ejbCtx.lookup("MyStatless");
home = (MyStatlessHome)PortableRemoteObject.narrow(objRef, MyStatlessHome.class);
MyStatless clientStatless = (MyStatless)home.create();
and I have configured ejb-ref in ejb.jar.xml :
<ejb-ref >
<ejb-ref-name>ejb/MyStatless</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
it.csi.oss.clusterejb.interfaces.MyStatlessHome
it.csi.oss.clusterejb.interfaces.MyStatless
</ejb-ref>
and in jboss.xml :
<ejb-ref>
<ejb-ref-name>ejb/MyStatless</ejb-ref-name>
<jndi-name>jnp://cst001.csi.it:1100/ejb/MyStatlessClient</jndi-name>
</ejb-ref>
In this case I obtain following exception :
2006-05-18 17:26:58,295 ERROR [org.jboss.ejb.plugins.LogInterceptor] RuntimeException in method: public abstract
java.lang.String it.csi.oss.clusterejb.interfaces.MyStatlessClient.getNome(java.lang.String,int) throws
java.rmi.RemoteException:
java.lang.ClassCastException
at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:293)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:134)
at it.csi.oss.clusterejb.ejb.MyStatlessClient.getNome(MyStatlessClient.java:154)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
..
..
..
Questions :
A) Is there a way to have "call by reference" between ejbs inside the same ear and "call by value" between ejbs across different ears ?
B) Is there a solution of the point 3) ?
thanks
Davide Pasquero