2017-05-08 54 views
0

我正在開發Java中的REST應用程序,並且在WildFly 8中運行WebService時,這個錯誤總是出現在我身上,我已經嘗試過搜索互聯網但沒有成功。運行wild Error的錯誤

ERROR:WELD-000071:管理bean類org.apache.cxf.jaxrs.provider.SourceProvider必須@Dependent

的web.xml

<?xml version="1.0" encoding="utf-8"?> 
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" 
version="2.4"> 
<display-name>ProjetoRefImplWS</display-name> 
<description>ProjetoRefImplWS</description> 
<context-param> 
    <param-name>contextConfigLocation</param-name> 
    <param-value>classpath:beans.xml</param-value> 
</context-param> 
<listener> 
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
</listener> 
<servlet-mapping> 
    <servlet-name>Services</servlet-name> 
    <url-pattern>/*</url-pattern> 
</servlet-mapping> 
<servlet> 
    <servlet-name>Services</servlet-name> 
    <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class> 
</servlet> 

的pom.xml

<dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-web</artifactId> 
     <version>3.2.13.RELEASE</version> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.cxf</groupId> 
     <artifactId>cxf-rt-frontend-jaxrs</artifactId> 
     <version>3.1.1</version> 
     <exclusions> 
      <exclusion> 
       <groupId>org.apache.geronimo.specs</groupId> 
       <artifactId>geronimo-javamail_1.4_spec</artifactId> 
      </exclusion> 
     </exclusions> 
    </dependency> 
    <dependency> 
     <groupId>com.fasterxml.jackson.jaxrs</groupId> 
     <artifactId>jackson-jaxrs-json-provider</artifactId> 
     <version>2.8.1</version> 
    </dependency> 
    <dependency> 
     <groupId>io.swagger</groupId> 
     <artifactId>swagger-jaxrs</artifactId> 
     <version>1.5.6</version> 
    </dependency> 

Erro:

11:33:17,704 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC000001: Failed to start service jboss.deployment.unit."ProjetoRefImplWs-0.0.1-SNAPSHOT.war".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."ProjetoRefImplWs-0.0.1-SNAPSHOT.war".WeldStartService: Failed to start service at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) [jboss-msc-1.2.2.Final.jar:1.2.2.Final] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_102] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_102] at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_102] Caused by: org.jboss.weld.exceptions.DefinitionException: WELD-000071: Managed bean class org.apache.cxf.jaxrs.provider.SourceProvider must be @Dependent at org.jboss.weld.bean.ManagedBean.checkType(ManagedBean.java:198) at org.jboss.weld.bean.AbstractBean.initializeAfterBeanDiscovery(AbstractBean.java:105) at org.jboss.weld.bean.ManagedBean.initializeAfterBeanDiscovery(ManagedBean.java:113) 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:60) at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:53) at java.util.concurrent.FutureTask.run(FutureTask.java:266) [rt.jar:1.8.0_102] ... 3 more

+0

您將應用程序配置爲使用Spring作爲DI框架,但WELD也試圖執行依賴注入? –

+0

我認爲你遇到了與此處相同的問題:http://stackoverflow.com/a/34418949/424903。也許我的答案(在這裏鏈接)也可以解決這個問題。或者升級到更現代的Wildfly版本也可能會讓它消失。但是,你可能仍然在蜻蜓8出於某種原因(不是在預算升級)。 – Gimby

回答

0

你可以在你的應用程序確保您的beans.xml文件下面的以下內容:

<?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" 
     bean-discovery-mode="annotated"> 
</beans> 

檢查豆發現-mode屬性。其他可能的值是'無'和'全部'。

+0

謝謝你,爲我工作。 – Lau13