1 Reply Latest reply on Oct 27, 2011 5:21 AM by jaikiran pai

    JNDI naming issue:EJB3.0 in JBoss AS7

    duan xz Newbie

      bug trace:

      javax.naming.NameNotFoundException: StatelessUserManager/UserManagerBean!com.pnft.ejb.UserManager -- service jboss.naming.context.java.app.UserManagerLocalWebClient.StatelessUserManager."UserManagerBean!com.pnft.ejb.UserManager" org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:87) org.jboss.as.naming.NamingContext.lookup(NamingContext.java:173) org.jboss.as.naming.InitialContext.lookup(InitialContext.java:57) org.jboss.as.naming.NamingContext.lookup(NamingContext.java:209) javax.naming.InitialContext.lookup(InitialContext.java:392) org.apache.jsp.index2_jsp._jspService(index2_jsp.java:101) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:847) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:326) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:253) javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

       

      java code(LocalWebClient):

       

      InitialContext ctx = new InitialContext();
      
      UserManager userManager = (UserManager)ctx.lookup("java:app/StatelessUserManager/UserManagerBean!com.pnft.ejb.UserManager");
                                                                                                                                                                                  
      User user = new User();
        
      user.setUsername("张三");
        
      user.setPassword("zhangsan");
      
      out.println(user.getUsername());
      
      userManager.addUser(user);
      
      out.println("用户信息已经被成功保存,它的ID是:" + user.getId());
      
      

      java code :

       

      package com.pnft.ejb;
      import javax.ejb.Local;
      import javax.ejb.Stateless;
      
      @Stateless
      @Local
      public class UserManagerBean implements UserManager 
      {
               public void addUser(User user) 
               {
                         System.out.println("User name: " + user.getUsername() + "已经被成功保存!");
                         System.out.println("The user's password is: " + user.getPassword());
                         user.setId(10);
               }
      }
      
      

       

      In the documentation( https://docs.jboss.org/author/display/AS7/Order+Application+Migration+from+EAP5.1+to+AS7 )

       

      In addition to the change to injection, which was supported in EAP 5.1.0, the lookup name changed from:
      
      OrderManagerApp/DistributionCenterManagerBean/local
      
      
      
      
      
      
      
      to:
      
      java:app/OrderManagerEJB/DistributionCenterManagerBean!services.ejb.DistributionCenterManager
      
      
      
      
      
      
      
      

       

      any help will be apprecite.

       

      thanks!

       

      Regards,

      duanxz