从JBoss 7迁移后,Wildfly 14 CDI:JED第三部分上的WELD-001408 [英] Wildfly 14 CDI: WELD-001408 on 3rd part JAR after migration from JBoss 7

查看:332
本文介绍了从JBoss 7迁移后,Wildfly 14 CDI:JED第三部分上的WELD-001408的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在将一些用Java 5、6和7编写的旧系统迁移到Java 8,并从JBoss 7迁移到Wildfly 14. 迁移之后,我总是会遇到这种错误:

We are migrating a few old systems written in Java 5, 6 and 7 to Java 8 and from JBoss 7 to Wildfly 14. After the migration, I get all the time this kind of error:

WELD-001408: Unsatisfied dependencies for type InterfaceTypeConverterProvider with qualifiers @Named

我知道从CDI 1.2开始,事情发生了变化,@ Inject无法像以前那样工作,因此需要进行一些重构. 我遇到了很多这样的错误,其中一些是我自己项目中的类,试图将其他类也注入到我的项目中,这些我可以修复.

I understand that from CDI 1.2 things changed and the @Inject don't work as it used to be and it need some refactoring. I got many errors like this, some of them are classes in my own project that try to Inject other classes also inside my project, those ones I can fix.

问题是:我的项目加载了一些试图从外部注入其他类的类,这些类是jar依赖项,我无法对其进行控制,而且我无法更改这些jar上的代码.

The problem is: My project loads some classes that tries to inject other classes from outside, that are jar dependencies that I have no control over it and I can't change the code on those jars.

例如:

11:15:54,552 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC000001: Failed to start service jboss.deployment.unit."myApp-war-9.2-JAVA8-SNAPSHOT.war".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."myApp-war-9.2-JAVA8-SNAPSHOT.war".WeldStartService: Failed to start service at org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1728)
  at org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1556)
  at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
  at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)
  at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)
  at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1378)
  at java.lang.Thread.run(Thread.java:748)
Caused by: org.jboss.weld.exceptions.DeploymentException: Exception List with 46 exceptions:
Exception 0 :
org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type InterfaceTypeConverterProvider with qualifiers @Named
  at injection point [BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedMethod] @Inject public thirdPartJar.converter.context.AbstractConverter.setTypeConverterProvider(@Named InterfaceTypeConverterProvider)
  at thirdPartJar.converter.context.AbstractConverter.setTypeConverterProvider(AbstractConverter.java:0)
WELD-001475: The following beans match by type, but none have matching qualifiers:
  - Managed Bean [class thirdPartJar.converter.context.TypeConverterProvider] with qualifiers [@Any @Default]

该错误在类 thirdPartJar.converter.context.AbstractConverter 中显示了问题,我无法触及该代码……所以,我该怎么办? 是否可以降级Wildfly Weld或强制其使用旧版本的CDI?

The error shows the problem in the class thirdPartJar.converter.context.AbstractConverter and I can't touch the code on that one... so, what should I do ? Is it possible to downgrade Wildfly Weld or force it to use an older version of CDI ?

这是我的bean.xml,其中包含全部发现内容,但仍然找不到实现.

This is my beans.xml with the discover all but it still can't find the implementations.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
       version="1.2" bean-discovery-mode="all">
</beans>

推荐答案

beans.xml始终仅适用于其所在的存档(无论是jar还是war).因此,您仅将bean-discovery-mode设置为您自己的存档,而不是第三方的存档.

The beans.xml always only applies to the archive it's in (be it jar or war). So you're setting the bean-discovery-mode only for your own archive, not for the 3rd party one.

最简单的选择:重新包装第三方罐子,并放入配件beans.xml.

Easiest option: Repackage the 3rd party jar and include a fitting beans.xml.

非侵入式选项:编写一个提供期望的bean的生产者.通常,这可以是一种简单的方法:

Non-intrusive option: Write a producer that supplies the expected beans. Normally, this can be a simple method:

@Produces
@Named
public InterfaceTypeConverterProvider createInterfaceTypeConverterProvider() {
    return new InterfaceTypeConverterProvider();
}

我认为班上没有打针.否则,它应该已经启用了cdi.

I take it that there is no injection within the class. Otherwise it should already have been cdi enabled.

这篇关于从JBoss 7迁移后,Wildfly 14 CDI:JED第三部分上的WELD-001408的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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