WELD-001409不明确的依赖关系 [英] WELD-001409 Ambiguous dependencies

查看:921
本文介绍了WELD-001409不明确的依赖关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将我的ejbProfileEJB注入我的jsf托管beanSampleController,如下所示:

I want to inject my ejb "ProfileEJB" into my jsf managed bean "SampleController" like so:

@Stateless
@LocalBean
public class ProfileEJB {

    @PersistenceContext
    private EntityManager em;

    public Profile create(Profile p) {
        em.persist(p);
        return p;
    }

}

SampleController:

SampleController:

@Named(value = "sampleController")
@ViewScoped
public class SampleController {

    @Inject
    private ProfileEJB profileBean;

    public SampleController() {
    }

}

问题是我收到以下错误:

The problem is i get the following error:

CDI deployment failure:WELD-001409 Ambiguous dependencies for type [ProfileEJB] with qualifiers [@Default] at injection point [[BackedAnnotatedField] @Inject private com.example.controller.SampleController.profileBean]. Possible dependencies [[Session bean [class com.example.ejb.ProfileEJB with qualifiers [@Any @Default]; local interfaces are [ProfileEJB], Session bean [class com.example.ejb.ProfileEJB with qualifiers [@Any @Default]; local interfaces are [ProfileEJB]]]

我可以从消息中了解到有两个相同的bean和它不能决定注入哪些,但我不知道为什么有两个相同的豆?有人可以向我解释一下吗?
非常感谢!

I can understand from the message that there are two same beans and it cannot decide which to inject but i don´t know why there are two same beans? Can someone please explain it to me? Thank your very much!

推荐答案

对于将来寻找解决方案的任何人:从Glassfish 4.0迁移到4.1解决了这个问题。不要问我为什么

For anyone in the future searching for a solution: moving from Glassfish 4.0 to 4.1 solved the problem. Don´t ask me why

这篇关于WELD-001409不明确的依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆