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:
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();
}
}
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 love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With