Hi to all,
I'm new to java and ejb development and I've spend last two days truing to acess and ejb local interface from within another ejb in the same glassfish server
This is the first bean and it works fine when I access its remote interface fron the client application
@Stateful (name="BookBean", mappedName="ejb/BookBeanJNDI")
@Local(LocalBookIntf.class)
@Remote(BookIntf.class)
public class BookBean implements BookIntf, LocalBookIntf {
...
}
public interface BookIntf { ... }
public interface LocalBookIntf { ... }
Then I wrote a second ejb than try to access the BookBean Local Interface to expose the services in its own Remote interface (it's just wrapper with no real life meanings except learning how to to do )
I've tried to use the @EBJ annotation to get a reference to the BookBean Local Interface (I don't how if it matters but the two bean are in two different packege and in two different jar files)
@Stateful (name="WrapBookBean", mappedName="ejb/WrapBookBeanJNDI")
@Remote(BookIntf.class)
public class WrapBookBean implements BookIntf {
@EJB (name="ejb/CartBean", beanInterface=LocalCartIntf.class,beanName="BookBean")
LocalBookIntf realBean;
}
From the client application I use this code to get the remote bean interface :
Properties props=new Properties();
props.setProperty(Context.INITIAL_CONTEXT_FACTORY,"com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("org.omg.CORBA.ORBInitialHost", "10.10.1.155");
props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
InitialContext cntx = new InitialContext(props);
BookIntf bookBean = (BookIntf) cntx.lookup("ejb/WrapBookBeanJNDI");
And I get the following exception (Note that everithing works fine if I use "ejb/BookBeanJNDI" instead of "ejb/WrapBookBeanJNDI" in the context lookup)
javax.naming.NamingException: ejb ref resolution error for remote business interfaceit.metodoshoes.ejb.beans.BookBean.BookIntf [Root exception is java.lang.reflect.UndeclaredThrowableException]
at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:425)
at com.sun.ejb.containers.RemoteBusinessObjectFactory.getObjectInstance(RemoteBusinessObjectFactory.java:74)
at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:403)
at javax.naming.InitialContext.lookup(Unknown Source)
at it.metodoshoes.ejb.clients.BookClient.BookBeanClient.run(BookBeanClient.java:32)
at it.metodoshoes.ejb.clients.BookClient.BookBeanClient.main(BookBeanClient.java:15)
Caused by: java.lang.reflect.UndeclaredThrowableException
at $Proxy126.create(Unknown Source)
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:597)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:154)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:687)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:227)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1846)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1706)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:1088)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:223)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:806)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispatch(CorbaMessageMediatorImpl.java:563)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWork(CorbaMessageMediatorImpl.java:2567)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)
Caused by: javax.ejb.CreateException: ERROR creating stateful SessionBean
at com.sun.ejb.containers.StatefulSessionContainer.createRemoteBusinessObjectImpl(StatefulSessionContainer.java:694)
at com.sun.ejb.containers.EJBHomeImpl.createRemoteBusinessObjectImpl(EJBHomeImpl.java:123)
at com.sun.ejb.containers.EJBHomeInvocationHandler.invoke(EJBHomeInvocationHandler.java:189)
... 16 more
Caused by: com.sun.enterprise.InjectionException: Exception attempting to inject Unresolved Ejb-Ref ejb/BookBean_at_jndi: @null_at_it.metodoshoes.ejb.beans.BookBean.LocalBookIntf_at_Session@BookBean into class it.metodoshoes.ejb.beans.WrapBookBean.WrapBookBean
at com.sun.enterprise.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:387)
at com.sun.enterprise.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:206)
at com.sun.enterprise.util.InjectionManagerImpl.injectInstance(InjectionManagerImpl.java:127)
at com.sun.ejb.containers.StatefulSessionContainer.createBeanInstance(StatefulSessionContainer.java:926)
at com.sun.ejb.containers.StatefulSessionContainer.createRemoteBusinessObjectImpl(StatefulSessionContainer.java:664)
... 18 more
Caused by: javax.naming.NameNotFoundException: #it.metodoshoes.ejb.beans.BookBean.LocalBookIntf not found
at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.java:216)
at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:188)
at com.sun.enterprise.naming.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:74)
at com.sun.enterprise.naming.LocalSerialContextProviderImpl.lookup(LocalSerialContextProviderImpl.java:111)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:398)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at com.sun.enterprise.naming.NamingManagerImpl.lookup(NamingManagerImpl.java:922)
at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:173)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:396)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at com.sun.enterprise.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:287)
... 22 more
I'm sure the problem is the way I use to get the LocalBeanInterface of BookBeam from WrapBean. Can someone expalin me what is the correct way to do such a thing ?
Thanks to all
Luca
[Message sent by forum member 'metodoshoes' (metodoshoes)]
http://forums.java.net/jive/thread.jspa?messageID=282470