external ejb reference not being picked up
eustace Feb 22, 2002 8:00 AMhello,
i'd be very grateful if anyone can shed light on this. I know it's a bit of a newbie question, but I've tried pretty much everything and can't seem to get it to work.
if you have any idea at all i'd love to hear it.
I'm deploying a couple of beans (Cabin and TravelAgent)from O'Reilly's EJBs 3 book. I deploy them in separate jars.
One of the beans calls the other via it's remote interface, and I declare the <ejb-ref> in ejb-jar.xml and jboss.xml as per the jboss online docs on declaring an external reference (http://www.jboss.org/online-manual/HTML/ch07s13.html).
when I run a client for TravelAgent jboss says it can't find the remote interface of CabinBean thus: java.lang.ClassNotFoundException: com.titan.cabin.CabinHomeRemote
i've run test clients against CabinBean on it's own, and they work fine.
this is the full error message:
[11:28:44,988,StatelessSessionContainer] invoke returned an exception
java.rmi.ServerException: null
Embedded Exception
null; nested exception is:
javax.ejb.EJBException: null
Embedded Exception
null
javax.ejb.EJBException: null
Embedded Exception
null
at com.titan.travelagent.TravelAgentBean.listCabins(TravelAgentBean.java:56)
at java.lang.reflect.Method.invoke(Native Method)
at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(Stateless
SessionContainer.java:569)
at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSes
sionInstanceInterceptor.java:67)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.
java:98)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.j
ava:156)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:65)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:131
)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:166)
at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java
:280)
at org.jboss.ejb.Container.invoke(Container.java:528)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1555)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
at org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerIn
voker.java:411)
at java.lang.reflect.Method.invoke(Native Method)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:241)
at sun.rmi.transport.Transport$1.run(Transport.java:142)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:139)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:443)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:64
3)
at java.lang.Thread.run(Thread.java:484)
java.lang.ClassNotFoundException: com.titan.cabin.CabinHomeRemote
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:195)
at sun.rmi.server.MarshalInputStream.resolveProxyClass(MarshalInputStream.java:1
83)
at java.io.ObjectInputStream.inputProxyClassDescriptor(ObjectInputStream.java:98
2)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1186)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:386)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
at java.rmi.MarshalledObject.get(MarshalledObject.java:138)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:369)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:349)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at com.titan.travelagent.TravelAgentBean.listCabins(TravelAgentBean.java:25)
at java.lang.reflect.Method.invoke(Native Method)
at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(Stateless
SessionContainer.java:569)
at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSes
sionInstanceInterceptor.java:67)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.
java:98)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.j
ava:156)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:65)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:131
)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:166)
at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java
:280)
at org.jboss.ejb.Container.invoke(Container.java:528)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1555)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
at org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerIn
voker.java:411)
at java.lang.reflect.Method.invoke(Native Method)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:241)
at sun.rmi.transport.Transport$1.run(Transport.java:142)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:139)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:443)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:64
3)
at java.lang.Thread.run(Thread.java:484)
*******ejb-jar.xml********
<?xml version="1.0"?>
<!DOCTYPE ejb-jar PUBLIC
"-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
"http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<enterprise-beans>
<ejb-name>TravelAgentEJB</ejb-name>
com.titan.travelagent.TravelAgentHomeRemote
com.titan.travelagent.TravelAgentRemote
<ejb-class>com.titan.travelagent.TravelAgentBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<ejb-ref>
<!-- requires an entry in weblogic-ejb-jar.xml also -->
<ejb-ref-name>CabinEJB</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
com.titan.cabin.CabinHomeRemote
com.titan.cabin.CabinRemote
</ejb-ref>
<security-identity><use-caller-identity/></security-identity>
</enterprise-beans>
<assembly-descriptor>
*******jboss.xml*******
<?xml version="1.0" encoding="UTF-8"?>
<enterprise-beans>
<ejb-name>TravelAgentEJB</ejb-name>
<ejb-ref>
<ejb-ref-name>CabinEJB</ejb-ref-name>
<jndi-name>CabinEJB</jndi-name>
</ejb-ref>
<jndi-name>TravelAgentEJB</jndi-name>
</enterprise-beans>
******Here's the relevant snippets of code:******
****client of CabinBean- works fine
Object ref =
jndiContext.lookup("CabinEJB");
CabinHomeRemote home = (CabinHomeRemote)
PortableRemoteObject.narrow(ref,CabinHomeRemote.class);
****line in TravelAgent client that throws the exception:
String list [] = travelAgent.listCabins(SHIP_ID,BED_COUNT);
*****relevant portion of listCabins method in TravelAgentBean:
public String [] listCabins(int shipID, int bedCount) {
try {
javax.naming.Context jndiContext = new InitialContext();
Object obj =
jndiContext.lookup("CabinEJB");
CabinHomeRemote home = (CabinHomeRemote)
javax.rmi.PortableRemoteObject.narrow(obj,CabinHomeRemote.class);
***thanks -e