Digital Marketing

How to fix: Exception while deploying the app: java.lang.RuntimeException: Cannot resolve reference Remote ejb-ref name=[...]because there are more than 1 ejbs in the application with interface

Bean injected by @EJB could be an interface or a no-interface view bean. As long as there is only one implementation of the interface, it will be injected without any ceremony. However, if there are more than 1 ejbs  in the application with the same interface, configuration is required to disambiguate the choice.

Enhancement of the @EJB annotation with the beanName attribute fixes the problem. The value of the beanName attribute is the simple name (getSimpleName) of the desired bean.

@EJB(beanName="MyAnotherBean")
I88CABean bean;

The dependency injection can also be configured in the deployment descriptor (XML configuration) instead of annotations.

Both deployment descriptor (XML configuration) and annotation configuration are string based matching.

Comments

Popular posts from this blog

How to delete / clear queue of PowerMTA