0

I'm developing a REST application in Java and when running the WebService in WildFly 8 this error always appears to me, I've already tried searching the internet but without success.

ERROR: WELD-000071: Managed bean class org.apache.cxf.jaxrs.provider.SourceProvider must be @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

Lau13
  • 128
  • 1
  • 3
  • 10
  • you configured your app to use Spring as DI framework, but WELD is also trying to do dependency-injections? – P.J.Meisch May 08 '17 at 12:37
  • I think you are experiencing the same problem as here: http://stackoverflow.com/a/34418949/424903 . Perhaps my answer (linked here) will resolve this problem too. Alternatively upgrading to a more modern version of Wildfly will probably also make it go away. But you're probably still on Wildfly 8 for a reason (not in the budget to upgrade). – Gimby May 08 '17 at 15:04

1 Answers1

0

Can you make sure your beans.xml file in your application has the following below:

<?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> 

Check the bean-discovery-mode attribute. Other possible values are 'none' and 'all'.

Viral Gohel
  • 316
  • 1
  • 7