I've got a subresource class which must be initialized with a parameter from the path and which also contains a reference to an EJB which must be injected.
Resource class:
@Path("widgets")
public class MasterResource{
@Inject
WidgetBean widgets;
@Context
ResourceContext rc;
@Path("{year}")
public WidgetArchives wArchives(@PathParam("year") String year){
return rc.initResource(new WidgetArchiveResource(year));
}
}
Subresource class
public class WidgetArchiveResource{
@Inject
WidgetBean widgets;
public WidgetArchiveResource(String year){
....code
}
@GET
public String doGet(){
....code using WidgetBean
}
}
When I invoke get with the year, I see the following error:
org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at SystemInjecteeImpl(requiredType=WidgetBean,parent=WidgetArchiveResource,qualifiers={},position=-1,optional=false,self=false,unqualified=null,542790913)
I'm new to Java EE. What am I doing wrong?