EJB Access Across Ears - java.lang.NullPointerException in S
rigriff Mar 6, 2006 3:04 PMI was wondering if someone could enumerate the touch points to ensure that one can access an EJB that resides within one EAR from another EAR.
I am currently running up against a problem with the 'create' method of an EJB whose context and Home Interface I can successfully retrieve from lookup and narrow calls, respectively.
I am using JBoss 3.2.1 as my app server and am attempting to create/invoke methods from one EJB (indirectly using a delegate) on an EJB that resides within in an external EAR file.
Briefly, I have two ears. One application archive contains the EJB that I am invoking and one contains an EJB for an additional business method.
I think I have created the appropriate <ejb-ref> entry in my ejb-jar.xml and the EJB client stubs are deployed in a jar in the server/lib directory.
Any help that you can provide me will be much appreciated.
here is the suspect code snippet:
--------------------------------------------------------------------------------
public class AVSDelegate {
//this is required by the AVS Service as an Integer
public final static int CNSMR_ID = 1;
private final static String SERVANT_NAME = "ejb/AVSServiceEJB";
private InitialContext ctx = null;
private void initializeContext() throws NamingException {
if (ctx == null ) {
ctx = new InitialContext();
}
}
private AVSServantExchange getServant() throws NamingException, RemoteException, CreateException {
initializeContext();
Object o = ctx.lookup(SERVANT_NAME);
AVSServantExchange avsservant = null;
if ( o != null) {
AVSServantHome avsh = (AVSServantHome) PortableRemoteObject.narrow(o,AVSServantHome.class);
avsservant = avsh.create();
}
return avsservant;
}
public String ServantHello() {
AVSServantExchange servant = null;
String test = null;
try {
servant = getServant();
} catch ( RemoteException re) {
throw new RuntimeException("Could Not Establish Connection to External Servant\n");
} catch ( NamingException ne) {
throw new RuntimeException("Could not Resolve External Servant\n");
} catch ( CreateException cre) {
throw new RuntimeException("Could not Create AVS Servant\n");
}
try {
test = servant.echo("Hello Monkey");
} catch (RemoteException e) {
throw new RuntimeException("Could not execute external method\n"+e);
}
return test;
}--------------------------------------------------------------------------------
on calling the AVSServantHome's 'create' method. I get the following Runtime Exception:
2:57:38,991 ERROR [LogInterceptor] TransactionRolledbackException, causedBy:
java.lang.NullPointerException
at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invokeHome(StatelessSessionContainer.java:592)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:206)
at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invokeHome(StatelessSessionInstanceInterceptor.java:51)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:88)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:243)
at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:74)
at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:92)
at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:120)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:93)
at org.jboss.ejb.StatelessSessionContainer.internalInvokeHome(StatelessSessionContainer.java:310)
at org.jboss.ejb.Container.invoke(Container.java:694)
at sun.reflect.GeneratedMethodAccessor160.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:101)
at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:83)
at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:45)
at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:173)
at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)
at $Proxy259.create(Unknown Source)
at server.common.business.ezquote.worker.AVSDelegate.getServant(AVSDelegate.java:47)
at server.common.business.ezquote.worker.AVSDelegate.processOrder(AVSDelegate.java:88)
at ipos.ejb.impl.ezquote.EZQuoteServantBean.orderEz(EZQuoteServantBean.java:99)
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.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:629)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:243)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:104)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:117)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:322)
at org.jboss.ejb.Container.invoke(Container.java:674)
at sun.reflect.GeneratedMethodAccessor160.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:359)
at sun.reflect.GeneratedMethodAccessor159.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:534)
12:57:39,022 ERROR [LogInterceptor] EJBException, causedBy:
java.lang.RuntimeException: Could Not Establish Connection to External Servant