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>
@Produces
is not@javax.ws.rs.Produces
, but rather,@javax.enterprise.inject.Produces
– maress@javax.enterprise.inject.Produces
. now it's working. But why doesn't@javax.ws.rs.Produces
work? All my other factories use thews.rs
. I'm very new to javaee, so an explanation would be great :) – Lukas