@Inject does not work EJB calls its method

Platform: JBoss AS 7.1.1.

I have a beanless method that should call another method of the same bean but must go through the EJB container.

@Stateless public class OrderManager { @Resource SessionContext ctx; @Inject MailUtil mm; Logger logger = Logger.getLogger("Test"); public void method1() { if (mm == null) { logger.info("MailUtil is null"); } ctx.getBusinessObject(OrderManager.class).method2(); } @Asynchronous public void method2() { if (mm == null) { logger.info("MailUtil is null"); } } } 

Unfortunately, the introduced variable mm is null in method 2 (). Although inside the method 1 () there is a correctly entered variable mm.

Is this a defect in JBOss, or am I doing something wrong? Thanks.

+4
source share
2 answers

The same thing happened for me using WebSphere 8.5.5.5. The self-imposed bean had a null value in the beans entered.

The solution was to change the second method from private to public .

+1
source

According to Pete Muir, this is a mistake, but we are not sure whether this is fixed or not. Trying a new version of JBoss (build it from the source) will work. If this is a problem, create a report.

0
source

All Articles