在我的应用程序中添加tika解析器后,我的Spring应用程序中收到以下错误。我正在wildfly 10.1.1 final
上运行该应用程序。
11:11:30,371 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.deployment.unit."MyApp.war".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."MyApp.war".WeldStartService: Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
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.AbstractCachingMessageProvider
at org.jboss.weld.bean.ManagedBean.checkType(ManagedBean.java:208)
at org.jboss.weld.bean.AbstractBean.initializeAfterBeanDiscovery(AbstractBean.java:107)
at org.jboss.weld.bean.ManagedBean.initializeAfterBeanDiscovery(ManagedBean.java:122)
at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$AfterBeanDiscoveryInitializerFactory.doWork(ConcurrentBeanDeployer.java:136)
at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$AfterBeanDiscoveryInitializerFactory.doWork(ConcurrentBeanDeployer.java:127)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:63)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:56)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
at org.jboss.threads.JBossThread.run(JBossThread.java:320)
根据之前给出的解决方案,我在应用程序中包含以下文件:
-
jboss-all.xml
- 位置是 (src/main/resources/META-INF/
( -
beans.xml
- 位置是 (src/main/webapp/WEB-INF/
(
内容如下:
豆类.xml
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"
bean-discovery-mode="annotated">
</beans>
JBos-all.xml
<jboss xmlns="urn:jboss:1.0">
<weld xmlns="urn:jboss:weld:1.0" require-bean-descriptor="true"/>
</jboss>
如果还有什么要做的修复,请告诉我。我仍然得到与上面提到的相同的异常.
野蝇 12.0.0.Final 上的春季应用部署异常
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.DataSourceProvider
问题依赖关系
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<version>3.2.4</version>
</dependency>
解决方案帮助我修复异常是在 web.xml 上下文中重命名配置位置
<param-value>WEB-INF/beans.xml</param-value>
部署异常
<param-value>WEB-INF/application.xml</param-value>
部署成功
我在这里找到了一个解决方案:
https://stackoverflow.com/a/34418949
你应该创建一个包含以下内容的 jboss-all.xml:
<?xml version="1.0" encoding="UTF-8"?>
<jboss xmlns="urn:jboss:1.0">
<weld xmlns="urn:jboss:weld:1.0" require-bean-descriptor="true"/>
</jboss>
并将其放在webapp/META-INF下。
如果你正在开发一个 spring 应用程序,你可能只想关闭 CDI。 在这种情况下,您的beans.xml
应该是:
<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" bean-discovery-mode="none">
</beans>