次の休憩サービスがあります。
@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";
}
}
次の URL でリソースを使用しようとすると、host:port/root/geo/weather 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