Search code examples
gsoncdiweld

WELD-001408: Unsatisfied dependencies for type Gson with qualifiers @Default


All my other Injections are working but it's not working with gson. I have the feeling it's because it's an external package, but I can't resolve the issue. Here are my relevant files:

Producer:

public class GsonFactory {
    @Produces
    public Gson createGson(){return new GsonBuilder().createGson();}
}

injectionpoint:

@ApplicationScoped
public class SoundcloudAPIWrapper implements Serializable{

    @Inject
    private Gson gson;

    public SoundcloudAPIWrapper() {}

    ...

}

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_2_0.xsd"
    bean-discovery-mode="all" version="2.0">
</beans>

Solution

  • like @maress pointed out in the comment, I needed to replace @javax.ws.rs.Produces with @javax.enterprise.inject.Produces. It's now working