0

我试图通过 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;
    }
}
4

0 回答 0