Jersey 检索应用程序处理程序时的NPE

Jersey 检索应用程序处理程序时的NPE,jersey,dropwizard,hk2,Jersey,Dropwizard,Hk2,使用Dropwizard 1.3.17,我们检索ServiceLocator,如下所示: ServiceLocator ServiceLocator=((ServletContainer)环境.getJerseyServletContainer()).getApplicationHandler().getServiceLocator(); 当我们迁移到Dropwizard 2时,它变成: ServletContainer ServletContainer=(ServletContainer)O

使用Dropwizard 1.3.17,我们检索ServiceLocator,如下所示:

ServiceLocator ServiceLocator=((ServletContainer)环境.getJerseyServletContainer()).getApplicationHandler().getServiceLocator();
当我们迁移到Dropwizard 2时,它变成:

ServletContainer ServletContainer=(ServletContainer)Objects.requirennull(environment.getJerseyServletContainer());
ApplicationHandler ApplicationHandler=servletContainer.getApplicationHandler();
InjectionManager InjectionManager=applicationHandler.getInjectionManager();
服务定位器;
if(injectionManager instanceof ImmediateHk2InjectionManager)
{
serviceLocator=((ImmediateHk2InjectionManager)injectionManager.getServiceLocator();
}
else if(DelayedHK2注射管理器的注射管理器实例)
{
serviceLocator=((DelayedHk2InjectionManager)injectionManager).getServiceLocator();
}
其他的
{
抛出新的IllegalStateException(“期望有HK2注射经理”);
}

但是,ApplicationHandler为null。有什么想法吗?

我们重构了代码,不依赖org.eclipse.jetty.server.server.start之前的服务定位器。似乎在起作用。

对我来说,这似乎是一件球衣的问题