[J2EE:160199]Error resolving ejb-ref 'marin.tips.ejb3.stateless.hasa.OrchestratorBean/wineSearch' from module 'marin-tips-ejb3-hello-world-1.0-SNAPSHOT.jar' of application 'marin-tips'. The ejb-ref does not have an ejb-link and the JNDI name of the target bean has not been specified. Attempts to automatically link the ejb-ref to its target bean failed because multiple EJBs in the application were found to implement the 'marin.tips.ejb3.stateless.winesearchcommon.WineSearchFacade' interface. Please specify a qualified ejb-link for this ejb-ref to indicate which EJB is the target of this ejb-ref. at weblogic.ejb.container.deployer.EJBModule.activate(EJBModule.java:501)The failure resulted from trying to inject multi-implemented @Remote interface into another EJB by type:
@EJB()
public void setWineSearch(WineSearchFacade wineSearch) {
this.wineSearch = wineSearch;
}
The reason for the failure is pretty obvious: as there’s two implementation of my @Remote interface, the Weblogic container doesn’t know which one to inject.
The fix to this isn’t at all obvious, it’s quite obvious that you need to specify which of the implementation you wish to inject, but how to specify which one, that’s another matter.
In Weblogic land, the eventual fix is easy. Weblogic seems to force you to add name and mappedName attributes to your @Stateless annotation:
@Stateless(name = "WineSearchFacade", mappedName = "WineSearch")
public class WineSearchFacadeBean implements WineSearchFacade, WineSearchFacadeLocal { etc...
and you can use these in your injection annotation to reference the correct @Remote implementation:
@EJB(name = "WineSearchFacade", mappedName = "WineSearch")
public void setWineSearch(WineSearchFacade wineSearch) {
this.wineSearch = wineSearch;
}
1 comment:
Helped a lot, thank you!
Post a comment