У меня есть следующий сервис отдыха: Код зависимостейПочему CDI не работает?
@ApplicationPath("geo")
@Path("weather")
public class MainResource extends Application {
@Inject
private MainDep dep;
@GET
public String printGotIt() {
return "Got it!";
}
@GET
@Path("propaganda")
public String printPropaganda() {
return dep.printPropaganda();
}
}
MainDep:
public class MainDep {
public String printPropaganda() {
return "Interesting enterprise";
}
}
Когда я пытаюсь использовать ресурс по следующему адресу: хост: порт/корень/гео/погода GlassFish бросил javax .servlet.ServletException:
type Exception report
messageInternal Server Error
descriptionThe server encountered an internal error that prevented it from fulfilling this request.
exception
`javax.servlet.ServletException: Servlet.init() for servlet com.app.weather.rs.MainResource threw exception
root cause`
A MultiException has 1 exceptions. They are:
1. org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at Injectee(requiredType=MainDep,parent=MainResource,qualifiers={}),position=-1,optional=false,self=false,unqualified=null,22064320)
root cause
org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at Injectee(requiredType=MainDep,parent=MainResource,qualifiers={}),position=-1,optional=false
'public Set> getClasses()' не требуется. Спасибо. –
user2966560