焊缝在库罐中找不到CDI生产者方法 [英] Weld cannot find CDI producer method in library jar

查看:63
本文介绍了焊缝在库罐中找不到CDI生产者方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Wildfly 8.2.0.Final(我相信它使用的是Weld 2.2),我在Maven多模块项目中通过2个简单的类重现了此问题。一个产生 javax.ws.rs.client.Client ,另一个产生相同的注入点。 Arquillian部署失败,并显示 WELD-001408 :不满意的依赖关系。
生产者位于一个库jar中,该容器包含在 WEB-INF / lib 中,供消费者使用。生产者在 META-INF 中的 beans.xml 中具有 discovery-mode = annotation ,并且消费者拥有 WEB-INF 中的一个,其中 discovery-mode = all

Using Wildfly 8.2.0.Final, which I believe uses Weld 2.2, I've reproduced this issue with 2 simple classes in a Maven multimodule project. One produces a javax.ws.rs.client.Client, another has an injection point for the same. Arquillian deployment fails with WELD-001408: unsatisfied dependencies. The producer is in a library jar that gets included in the WEB-INF/lib for the consumer. Producer has a beans.xml in the META-INF with discovery-mode=annotation and the consumer has one in WEB-INF with discovery-mode=all.

复制步骤:
下载此项目,然后从根目录运行 mvn全新安装

Steps to reproduce: Download this project and run mvn clean install from the root directory.

这是一个严重的错误。还有一些其他这样的帖子焊接不满意的依赖关系,但大多数是因为缺少 beans.xml 。在CDI 1.2中, beans.xml 是可选的,尽管我的示例确实有几个。有任何想法吗?

This is a critical bug. There're some other SO posts about Weld unsatisfied dependencies but most of them are because a beans.xml was missing. With CDI 1.2, beans.xml is optional, though my example does have couple. Any ideas?

完整披露:也发布在Weld论坛上 255328

Full disclosure: Also posted in Weld forum 255328

推荐答案

经过几天尝试在另一个项目中重现该问题,但徒劳的我减少了针对CDI生产者和消费者的原始项目,并将代码发布在JBoss论坛中,还打开了JIRA WELD -1921 。 Martin Kouba发现问题是由使用错误的产品注释引起的!我使用的是 javax.ws.rs.Produces ,而不是 javax.enterprise.inject.Produces 。当我在Eclipse中自动导入该程序包并以某种方式选择了错误的程序包时,这显然不是故意的,并且一定会发生!
还有其他一些问题,但我无法解决所有问题。谢谢马丁。

After days of trying to reproduce the issue in another project, but in vain, I reduced the original project to a CDI produce and a consumer and posted the code in JBoss forum and also opened a JIRA WELD-1921. Martin Kouba found out that the problem was caused by using the wrong Produces annotation! Instead of javax.enterprise.inject.Produces, I had javax.ws.rs.Produces. This obviously wasn't intentional and must've happened when I auto-imported the package in Eclipse and somehow picked the wrong one! There were some other issues too but nothing I couldn't solve myself. Thanks a ton Martin.

这篇关于焊缝在库罐中找不到CDI生产者方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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