无法在Jboss 7中找到来自JNDI的BeanManager

时间:2013-07-30 04:27:25

标签: java ejb-3.0 jboss7.x cdi

我试图通过JNDI访问Jboss 7.1中的BeanManager,但没有成功。我尝试注入它并直接从JNDI访问它。我能够从客户端部署和访问会话bean。

以下是我的代码:

@Stateless
public class CustomerSessionBean implements ICustomerSessionBean{

    /**
     * Default constructor. 
     */
    public CustomerSessionBean() {
        // TODO Auto-generated constructor stub
    }

    public boolean addCustomer(Customer customer) {
        BeanManager beanManager = null;
        try {
            beanManager = (BeanManager) InitialContext.doLookup("java:comp/BeanManager");
        } catch (NamingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        System.out.println("Customer: "+customer+"Bean Manager"+beanManager);
        return true;
    }
}

0 个答案:

没有答案