Wildfly 上的 Tika-Parsers 部署问题 [英] Tika-Parsers deployment issue on Wildfly
问题描述
作为网络应用程序的一部分,我需要解析不同传入文件的文本内容.使用 tika-parsers 这应该很简单,但是一旦我尝试部署我的 web 应用程序在 Wildfly(测试了 V.8.2.1 和 V.10.0.0.RC4)上,我遇到了问题.
As part of a web application i need to parse textual content of different incoming files. This should be quite simple using tika-parsers, but as soon as i try to deploy my webapp on Wildfly (tested V.8.2.1 and V.10.0.0.RC4) i run into problems.
这是我在一个非常基本的 web 应用程序中的 maven 依赖:
This is my maven dependency in a very basic webapp:
<groupId>org.apache.tika</groupId>
<artifactId>tika-parsers</artifactId>
<version>1.11</version>
这是我在部署过程中遇到的错误(手动部署或使用 arquillian 进行测试):
This is the error i get during deployment (manual deployment or using arquillian for testing):
Caused by: java.lang.Exception: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"backend-test.war\".WeldStartService" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"backend-test.war\".WeldStartService: Failed to start service
Caused by: org.jboss.weld.exceptions.DefinitionException: WELD-000071: Managed bean with a parameterized bean class must be @Dependent: class org.apache.cxf.jaxrs.provider.SourceProvider"}}
我假设存在依赖冲突,但不知道如何避免它.豆类.xml?jboss-deployment-structure.xml?禁用任何 wildfly 模块?
I assume there is a dependency conflict, but have no clue on how to avoid it. beans.xml? jboss-deployment-structure.xml? Disable any wildfly modules?
问候,菲利普
推荐答案
除了 Tika 将一大堆有问题的依赖项以及大量非常不受欢迎的传递依赖项转储到您的运行时类路径之外,您还遇到了这个问题:
Besides the fact that Tika dumps a gigantic pile of questionable dependencies with a further mountain of very unwelcome transitive dependencies onto your runtime classpath, you are running into this issue:
http://weld.cdi-spec.org/documentation/#4
https://issues.jboss.org/browse/CDI-377
基本上是 CDI 1.1 中的不兼容问题,已在 CDI 1.2 中解决;在 Wildfly 中手动将 Weld 更新到版本 2.3.x 可能会完全解决问题.
Basically it is an incompatibility issue in CDI 1.1 that has been resolved in CDI 1.2; manually updating Weld to version 2.3.x in Wildfly may take the problem away entirely.
除非进行手动升级,否则您可以通过声明具有以下内容的 META-INF/jboss-all.xml 文件来消除问题.假设你有一场战争,确切的路径是 webapp/META-INF/jboss-all.xml.
Barring doing a manual upgrade, you can make the problem go away by declaring a META-INF/jboss-all.xml file with the following content. Assuming you have a war, the precise path is webapp/META-INF/jboss-all.xml.
<jboss xmlns="urn:jboss:1.0">
<weld xmlns="urn:jboss:weld:1.0" require-bean-descriptor="true"/>
</jboss>
并确保在您自己的需要 CDI 支持的模块中定义一个 WEB-INF/beans.xml 文件(再次:假设一场战争).这迫使 Weld 仅尝试配置包含 beans.xml 文件的模块,而 CXF 不会.
And make sure to define a WEB-INF/beans.xml file (again: assuming a war) in your own modules that need CDI support. This forces Weld to only try to configure modules which have a beans.xml file as part of them, which CXF will not.
除此之外,我会真正调查依赖树并查看通过 Tika 引入的内容;例如,您会发现 javax.inject API 被放在编译范围内,因此与您的应用程序一起部署,这是您真正不想要的.
Besides all that I would really investigate the dependency tree and see what is pulled in through Tika; for example you will find that the javax.inject API is put on the compile scope and thus deployed with your application, something you really do not want.
这篇关于Wildfly 上的 Tika-Parsers 部署问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!