Wildfly 11 部署中源自 deltaspike 的拦截器警告

Posted

技术标签:

【中文标题】Wildfly 11 部署中源自 deltaspike 的拦截器警告【英文标题】:Interceptor warnings in wildfly 11 deployment originating from deltaspike 【发布时间】:2019-01-04 07:44:04 【问题描述】:

在 Wildfly 11 中部署我的 test.war 期间,我看到了几个警告:

09:45:32,714 WARN  [org.jboss.weld.Validator] (MSC service thread 1-4) WELD-001478: Interceptor class org.apache.deltaspike.core.impl.throttling.ThrottledInterceptor is enabled for the application and for the bean archive test.war/WEB-INF/lib/deltaspike-core-impl-1.8.1.jar. It will only be invoked in the @Priority part of the chain.
09:45:32,714 WARN  [org.jboss.weld.Validator] (MSC service thread 1-4) WELD-001478: Interceptor class org.apache.deltaspike.core.impl.lock.LockedInterceptor is enabled for the application and for the bean archive test.war/WEB-INF/lib/deltaspike-core-impl-1.8.1.jar. It will only be invoked in the @Priority part of the chain.
09:45:32,715 WARN  [org.jboss.weld.Validator] (MSC service thread 1-4) WELD-001478: Interceptor class org.apache.deltaspike.core.impl.future.FutureableInterceptor is enabled for the application and for the bean archive test.war/WEB-INF/lib/deltaspike-core-impl-1.8.1.jar. It will only be invoked in the @Priority part of the chain.
09:45:32,722 WARN  [org.jboss.weld.Validator] (MSC service thread 1-4) WELD-001478: Interceptor class org.apache.deltaspike.jpa.impl.transaction.TransactionalInterceptor is enabled for the application and for the bean archive test.war/WEB-INF/lib/deltaspike-jpa-module-impl-1.8.1.jar. It will only be invoked in the @Priority part of the chain.
09:45:32,728 WARN  [org.jboss.weld.Validator] (MSC service thread 1-4) WELD-001478: Interceptor class org.apache.deltaspike.proxy.util.EnableInterceptorsInterceptor is enabled for the application and for the bean archive test.war/WEB-INF/lib/deltaspike-proxy-module-api-1.8.1.jar. It will only be invoked in the @Priority part of the 

这似乎是因为在我的 test.war 中的每个 beans.xml 中存在一些拦截器,例如 deltaspike-core -impl-1.8.1.jar

<class>org.apache.deltaspike.core.impl.throttling.ThrottledInterceptor</class>
<class>org.apache.deltaspike.core.impl.lock.LockedInterceptor</class>
<class>org.apache.deltaspike.core.impl.future.FutureableInterceptor</class>

是否可以从 beans.xml 中删除拦截器而不会造成伤害?

在 Wildfly 11 中使用 CDI 1.2,我认为不再需要在 beans.xml 中明确列出拦截器。

至少似乎存在一些(次要)问题应该由 deltaspike 开发人员调查?

【问题讨论】:

【参考方案1】:

这是 DeltaSpike 令人讨厌的黑魔法——他们试图保持 CDI 1.0 兼容,这意味着他们不能使用 @Priority(稍后介绍,CDI 1.1)作为在全球范围内启用其拦截器/装饰器/替代品的手段。为了使其正常工作,他们必须在 JAR 中包含 beans.xml,并在每个存档的基础上包含 enable it there。

但这还不是全部,他们正在通过使用an extension which promotes all their interceptors to globally enabled 来解决@Priority 的限制(例如,好像他们有@Priority)。

现在,我不确定您是否可以删除它 - 您可以轻松尝试看看它们是否仍然有效。但我不会碰它,因为 DS 在这方面似乎很脆弱。

至于 Weld 警告 - 它非常无害,Weld 只是告诉您在处理所有拦截器时:

它在beans.xml 中找到的那些(每个 bean 归档启用) 通过扫描类路径识别的那些;正在寻找 @Interceptor + @Priority(全局启用) 最终通过扩展启用(全局启用)

它发现一些拦截器是双向启用的,尽管如此,它们只会被调用一次。

总而言之,你不需要做任何事情,它应该仍然适合你。

【讨论】:

以上是关于Wildfly 11 部署中源自 deltaspike 的拦截器警告的主要内容,如果未能解决你的问题,请参考以下文章

如何将 root(/) 上下文中的 war 文件部署到 Wildfly 9.0.1 版

如何在 WildFly 10 中将爆炸战争部署为文件夹

域模式下的 Wildfly 不部署我的战争文件

使用 JDK11 设置的 Wildfly 服务器中的日志记录问题

使用 Wildfly 8.1.0 Final 部署 Java @Schedule

WildFly JNDI 查找部署在 WAR 中的本地 EJB