[jboss-user] [JNDI/Naming/Network] - javax.naming.NameNotFoundException: ejb not bound

pepelara do-not-reply at jboss.com
Sun Oct 5 07:26:11 EDT 2008


Hi,

I am trying to develop a CMP EJB 2.0 application and I found two problems,
both of them are the same listed below:
 

  | java.rmi.ServerException: EJBException:; nested exception is: 
  | 	javax.ejb.EJBException: javax.naming.NameNotFoundException: ejb not bound
  | 

The first one I have solved with the following code on the client,


  | // Get an initial context
  |       InitialContext jndiContext = new InitialContext(properties);
  |       System.out.println("Got client context");
  |       
  |       // Get a reference to the Bean
  |       //Object ref  = jndiContext.lookup("java:comp/env/ejb/Bookstore"); //java:comp/env/ejb/Bookstore
  |       //System.out.println("Got reference");
  |       
  |       // Get a reference from this to the Bean's Home interface
  |       BookstoreHomeRemote home = (BookstoreHomeRemote)
  |         PortableRemoteObject.narrow (jndiContext.lookup("BookstoreBean"), BookstoreHomeRemote.class);
  | 

But when I use JNDI on the Session Bean to call the Entity Bean, then theserver throws the exception above. The code is,


  | public class BookstoreBean implements SessionBean{
  | 
  | 	CMPBooksHomeRemote booksHome;
  | 	
  | 	public void ejbCreate() throws CreateException {
  | 	}
  | 	
  | 	public Collection booksList(){
  | 		Vector books = new Vector();
  | 
  | 	    try{
  | 	    	Context ctx = new InitialContext();
  | 	    	System.out.println("Got context in Session Bean");
  | 	    	
  | 	    	booksHome = (MPBooksHomeRemote)                      ctx.lookup("java:comp/env/ejb/CMPBooksHomeRemote");
  | 	    	System.out.println("Got booksHome");
  | 	    	
  | 			books = (Vector)booksHome.findAll();
  | 			
  | 	    } catch(NamingException ne){
  | 			throw new EJBException(ne);
  | 		} catch(RemoteException re){
  | 			throw new EJBException(re);
  | 		} catch (FinderException fe) {
  | 			throw new EJBException(fe);
  | 		}
  | 		return books;
  | 	}
  | 	
  | 	public void ejbRemove(){}
  | 	public void ejbActivate(){}
  | 	public void ejbPassivate(){}
  | 	public void setSessionContext(SessionContext sc){}
  | }
  | 

This is the log,


  | 2008-10-05 10:57:41,887 INFO  [STDOUT] Got context in Session Bean
  | 2008-10-05 10:57:41,888 ERROR [org.jboss.ejb.plugins.LogInterceptor] EJBException in method: public abstract java.util.Collection es.deusto.ejb.session.BookstoreRemote.booksList() throws java.rmi.RemoteException, causedBy:
  | javax.naming.NameNotFoundException: ejb not bound
  | 	at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
  | 	at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
  | 	at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
  | 	at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
  | 	at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
  | 	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:667)
  | 	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:774)
  | 	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
  | 	at javax.naming.InitialContext.lookup(InitialContext.java:351)
  | 	at es.deusto.ejb.session.BookstoreBean.booksList(BookstoreBean.java:30)
  | 	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:585)
  | 	at org.jboss.invocation.Invocation.performCall(Invocation.java:359)
  | 	at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:237)
  | 	at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:158)
  | 	at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:169)
  | 	at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:63)
  | 	at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:121)
  | 	at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:350)
  | 	at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:181)
  | 	at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:168)
  | 	at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205)
  | 	at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:138)
  | 	at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:648)
  | 	at org.jboss.ejb.Container.invoke(Container.java:960)
  | 	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:585)
  | 	at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
  | 	at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
  | 	at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
  | 	at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
  | 	at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
  | 	at org.jboss.invocation.unified.server.UnifiedInvoker.invoke(UnifiedInvoker.java:231)
  | 	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:585)
  | 	at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
  | 	at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
  | 	at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
  | 	at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
  | 	at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
  | 	at javax.management.MBeanServerInvocationHandler.invoke(MBeanServerInvocationHandler.java:201)
  | 	at $Proxy16.invoke(Unknown Source)
  | 	at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:769)
  | 	at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:573)
  | 	at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:387)
  | 	at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:166)
  | 

And I do not know the way to solved.
Please, help!

Thanking in advance,
pepelara


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4180423#4180423

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4180423



More information about the jboss-user mailing list