Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unsatisfied dependencies for type Set<Service> with qualifiers

I am new to work on the creation of web services(Restful api). following a simple tutorial of Java Brains for Restful web services. I am Getting the error which says something like "Unsatisfied dependencies for type Set with qualifiers @Default"

I have searched for different questions here, have tried below things:

  1. downloaded new server and connected it to my project and removed old server.
  2. updated guava dependencies and added its jar to my project.

still facing the error.

below is the server error log.

Severe: Exception while loading the app : CDI deployment failure:WELD-001408: Unsatisfied dependencies for type Set with qualifiers @Default at injection point [BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] @Inject com.google.common.util.concurrent.ServiceManager(Set) at com.google.common.util.concurrent.ServiceManager.(ServiceManager.java:0) org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type Set with qualifiers @Default at injection point [BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] @Inject com.google.common.util.concurrent.ServiceManager(Set) at com.google.common.util.concurrent.ServiceManager.(ServiceManager.java:0)

this is studentservice class which is providing data.

public class StudentService {
    public List<Student> getAllData() {
        Student s1 = new Student(1, "Sagar", 20);
        Student s2 = new Student(2, "Puneet", 23);
        List<Student> list = new ArrayList<>();
        list.add(s1);
        list.add(s2);
        return list;
    }
}

Below is my api class

@Path("/myfirstapi")
public class MyFirstAPI {
StudentService ss=new StudentService();
@GET
@Produces(MediaType.APPLICATION_XML)
public List<Student> gettext() {
    return ss.getAllData();
    }
}
like image 487
Sagar Khurana Avatar asked Jan 17 '17 11:01

Sagar Khurana


1 Answers

The cause of this error is usually a bad version of Guava. You may have a version of Guava < 16. You should check your classpath.

I can see 2 solutions :

  • If you are using CDI (you do not seem to), update Guava version with version >= 16.
  • Else disable CDI (remove beans.xml if present in classpath and disable implicit scanning in you application server).
like image 95
Rouliboy Avatar answered Nov 05 '22 22:11

Rouliboy