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