0

I'm having serious problems by trying to run this template project for setting up RESTful web services. I constantly get the exception

org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at Injectee(requiredType=ToDoService,parent=ToDoResource,qualifiers={}),position=-1,optional=false,self=false,unqualified=null,383253211)

I've read similar posts and most of them suggest using an AbstractBinder. I tried to do so by inserting a class

public class MyBinder extends AbstractBinder {
@Override
protected void configure() {
    bind(DefaultToDoService.class).to(ToDoService.class);
}
}

but now I don't know where to register it. I tried to do so inside the RestConfiguration class which extends Application, but the register method does not exist there... the Jersey doc does not seem very clear on that subject. If you could give me a little help that could save me a lot of time!

splinter123
  • 1,183
  • 1
  • 14
  • 34
  • I believe you simply add it to the class set in `getClasses` in `RestConfiguration`. – Baldy Jun 06 '14 at 12:34
  • I tried it, but nothing changed... – splinter123 Jun 08 '14 at 15:20
  • well I solved it by just calling the DefaultToDoService with a standard "new" statement, instead of injecting it. Honestly, I find this whole injection mechanism quite buggy and confusing, and pretty useless for relatively small applications. – splinter123 Jun 14 '14 at 17:05
  • possible duplicate of [Dependency injection with Jersey 2.0](http://stackoverflow.com/questions/16216759/dependency-injection-with-jersey-2-0) – kosgeinsky Oct 12 '14 at 18:44

0 Answers0