我有@Local接口(interface)
@Local
public interface IRepo
{
还有两个实现,但是只有1 bean实现
@Stateless(name = "RepoBean")
public class RepoBean implements IRepo
{
第二个
public class SimpleRepo implements ILogRepositoryIRepo
{
并使用
将其注入(inject)我的 Web 服务 @EJB(name = "RepoBean")
private IRepo repository;
它在 jboss
和 WebLogic
上运行良好。但在 GlassFish 3.1.1
上,我收到错误(部署时)
Cannot resolve reference Local ejb-ref name=RepoBean,Local 3.x interface =com.company.IRepo,ejb-link=null,lookup=,mappedName=,jndi-name=,refType=Session because there are 2 ejbs in the application with interface com.company.IRepo.
但我只有 1 个ejb 实现。
有任何想法吗?也许我可以使用一些部署描述符或其他东西。
EJB 3.0、Java EE 5
最佳答案
我真的不明白你想做什么,但是如果你有两个实现相同业务接口(interface)的bean,则必须使用“beanName”属性,如下所示:
@EJB(beanName = "RepoBean")
private IRepo repository;
--更新
看看这个:java.net/node/702013 。此问题存在一个错误问题:java.net/jira/browse/GLASSFISH-11684
似乎这只发生在 EJB-in-WAR 打包中。在 ejb jar 中不会发生。
关于java - @Local接口(interface)有很多实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12637848/