1 Reply Latest reply on Mar 6, 2002 3:18 PM by Matt Sales

    Extenral EJB Reference

    Matt Sales Newbie

      Hello,
      I'm having a hard time accessing an entity bean from a separate session bean in JBoss 2.4.4. Every time I try to access the entity bean's home interface (via the session bean), I get a classNotFound exception on the my.bean.pkg1.EntitybeanHome interface. I can access the entity bean's home interface via a client without a problem. Here's the relevant code (I think...):

      MySessionBean's ejb-jar.xml:
      ...

      <ejb-name>MySessBean</ejb-name>
      ...
      <ejb-ref>
      <ejb-ref-name>ejb/MyEnt</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      my.bean.pkg1.MyEntHome
      my.bean.pkg1.MyEnt
      </ejb-ref>
      ...

      ...

      Session Bean's jboss.xml:
      ...

      <ejb-name>MySessBean</ejb-name>
      <jndi-name>jn/Sess</jndi-name>
      <ejb-ref>
      <ejb-ref-name>ejb/MyEnt</ejb-ref-name>
      <jndi-name>jn/MyEnt</jndi-name>
      </ejb-ref>

      ...

      Entity Bean's jboss.xml:
      ...

      <ejb-name>MyEntBean</ejb-name>
      <jndi-name>jn/MyEnt</jndi-name>

      ...

      Finally, the MySessBean lookup code:
      I've tried
      jndiContext.lookup("java:comp/env/ejb/MyEnt");
      ,
      jndiContext.lookup("jn/MyEnt");
      ,
      and several other strings.

      The exception is not thrown when I create a new MyEntHome object... It is only thrown when I try to call a method using the new object.

      Thanks very much for any help, I hope this post isn't too confusing...

      For what it's worth, here's the server output:
      [10:56:55,624,MySessBean] TRANSACTION ROLLBACK EXCEPTION:
      javax.transaction.TransactionRolledbackException: null
      Embedded Exception
      null; nested exception is:
      javax.ejb.EJBException: null
      Embedded Exception
      null
      javax.ejb.EJBException: null
      Embedded Exception
      null
      at my.bean.pkg2.MySessBean.method(MySessBean.java:42)
      at java.lang.reflect.Method.invoke(Native Method)
      at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:542)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:82)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java(Compiled Code))
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java(Compiled Code))
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java(Compiled Code))
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java(Compiled Code))
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java(Compiled Code))
      at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java:286)
      at org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerInvoker.java(Compiled Code))
      at java.lang.reflect.Method.invoke(Native Method)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java(Compiled Code))
      at sun.rmi.transport.Transport$1.run(Transport.java(Compiled Code))
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java(Compiled Code))
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java(Compiled Code))
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:662)
      at java.lang.Thread.run(Thread.java:498)
      java.lang.ClassNotFoundException: my.bean.pkg1.MyEntHome
      at java.net.URLClassLoader.findClass(URLClassLoader.java(Compiled Code))
      at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))
      at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java(Compiled Code))
      at sun.rmi.server.MarshalInputStream.resolveProxyClass(MarshalInputStream.java:206)
      at java.io.ObjectInputStream.inputProxyClassDescriptor(ObjectInputStream.java:988)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java(Compiled Code))
      at java.io.ObjectInputStream.inputObject(ObjectInputStream.java(Compiled Code))
      at java.io.ObjectInputStream.inputObject(ObjectInputStream.java(Compiled Code))
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java(Compiled Code))
      at java.rmi.MarshalledObject.get(MarshalledObject.java(Compiled Code))
      at java.rmi.MarshalledObject.get(MarshalledObject.java(Compiled Code))
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:353)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:333)
      at javax.naming.InitialContext.lookup(InitialContext.java:351)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:421)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:457)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:333)
      at javax.naming.InitialContext.lookup(InitialContext.java:351)
      at my.bean.pkg2.MySessBean.method(MySessBean.java:19)
      at java.lang.reflect.Method.invoke(Native Method)
      at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:542)

        • 1. Re: Extenral EJB Reference
          Matt Sales Newbie

          In case anyone else has this problem...
          I finally found the answer after searching through archived posts.

          When you create a bean(A) that references another bean(B) externally, bean A must include bean B's interface classes in its jar file. I was wondering why the jboss examples had the interfaces in a separate package from the bean class, and now it makes sense...