[jboss-user] [EJB 3.0] - Stateless session bean not bound

dgdwinte do-not-reply at jboss.com
Tue Jul 17 16:28:58 EDT 2007


Hi,

back with another question: using JBoss 5 beta2, i cannot find my first stateless session bean using a JNDI-lookup from a servlet: 


  | 
  | 	   try{
  | 			Context jndiContext=getInitialContext(); 
  | 			Context ejbCtx = (Context) jndiContext.lookup("java:comp");
  | 			ArticleManagerLocal artman= (ArticleManagerLocal) ejbCtx.lookup("ArticleManager/local"); 
  | 			PrintWriter out=res.getWriter(); 
  | 			out.println("Test"); 
  | 			out.close();
  | 		} catch (javax.naming.NamingException ne){
  | 				ne.printStackTrace(); 
  | 				PrintWriter out=res.getWriter(); 
  | 				out.println("Test2");
  | 				out.close(); 
  | 		}
  | 	}
  | 	
  | 	private static javax.naming.Context getInitialContext() {
  |         try {
  |             java.util.Properties environment = new java.util.Properties();
  |             environment.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
  |             environment.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");
  |             environment.put(Context.PROVIDER_URL, "jnp://localhost:1099");
  |             return new javax.naming.InitialContext(environment);
  |         } catch(Exception e) {
  |             e.printStackTrace();
  |             return null;
  |         }
  |     }
  | 
  |  

I try to find the Session-bean ArticleManager using a JNDI-lookup, but I always get the following error-message: 


  | 22:22:12,359 ERROR [STDERR] javax.naming.NameNotFoundException: ArticleManager n
  | ot bound
  | 

However, when I have a look at the JNDI-view in the JBoss-server, I can see that my session-bean has been deployed: 


  | java:comp namespace of the component jboss.j2ee:service=EJB3,ear=texaco_deploy-1.0-SNAPSHOT.ear,jar=texaco_model-1.0-SNAPSHOT.jar,name=ArticleManager :
  | 
  |   +- UserTransaction (class: org.jboss.ejb3.tx.UserTransactionImpl)
  |   +- env (class: org.jnp.interfaces.NamingContext)
  |   |   +- be.erpsystem.texaco.articles.ArticleManager (class: org.jnp.interfaces.NamingContext)
  |   |   |   +- em (class: org.jboss.ejb3.entity.TransactionScopedEntityManager)
  | 
  | 

Finally, the code of my session-bean is as follows:


  | @Stateless (mappedName="ArticleManager") 
  | public class ArticleManager implements ArticleManagerRemote, ArticleManagerLocal {
  | 	@PersistenceContext (unitName="texaco") EntityManager em; 
  | 	public void testArticles(){
  | 		int i=0; 
  | 		i*=2; 
  | 	}
  | }
  | 

As I'm very new to EJB / EJB 3.0, this might be an obvious question. 

Any help however, is very appreciated! 

Thanks
Davy. 

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

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



More information about the jboss-user mailing list