注入EJB注释

时间:2016-09-19 07:42:54

标签: java ejb inject

当我在代码中使用注释@EJB时,一切正常

public class CatalogueDetailsPage extends AbstractBasePage {
    @EJB(lookup = "java:global/mobile.bank.services-1.0.5/api.ejb-1.1/CatalogueFacadeBean!by.softclub.common.api.ICatalogueService")
    private ICatalogueService iCatalogueService;
}

但是当我想要使用@Inject& @Produces我有错误空指针

public class CatalogueDetailsPage extends AbstractBasePage {
    @Inject
    @EJBBean
    private ICatalogueService iCatalogueService;
}

@Stateless
public class EJBFactory {

    @EJB(lookup = "java:global/mobile.bank.services-1.0.5/api.ejb-
    protected ICatalogueService iCatalogueService;

   @Produces
   @EJBBean
   public ICatalogueService getiCatalogueService() {
        return iCatalogueService;
    }
}

@Qualifier
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER })
public @interface EJBBean {

}

}

为什么会这样?

0 个答案:

没有答案