我正在使用Dropwizard api。当我使用0.7.2时它工作正常但是现在我把它改为0.8.2
我得到了你能找到的所有最奇怪的崩溃。但我设法解决了大部分问题。但是当我添加一个POJO参数
时,我无法启动服务器 @POST
@Path("remove")
@Produces(MediaType.TEXT_HTML)
@Consumes(MediaType.APPLICATION_JSON)
public Response removeUser(@Auth User user, User removedUser) {
if(user == null || user.getSuperAdmin() != 1){
return Response.status(401).build();
}
userDAO.delete(removedUser.getId());
return Response.ok().build();
}
如果你看一下代码。当我添加用户变量removedUser
时。我无法启动服务器。但当我删除它。它工作正常。
但我需要项目中的removedUser
我在项目的不同领域遇到同样的问题。所以可以帮助我解决这个问题的任何事情都被接受了
例外:
javax.ws.rs.core.Response}, nameBindings=[]}']
! at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:554) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:183) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:349) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:346) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.glassfish.jersey.internal.Errors.process(Errors.java:315) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.glassfish.jersey.internal.Errors.process(Errors.java:297) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:255) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:346) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:339) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:362) ~[support-server-0.0.0001.jar:0.0.0001]
! at javax.servlet.GenericServlet.init(GenericServlet.java:244) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:612) ~[support-server-0.0.0001.jar:0.0.0001]
! ... 36 common frames omitted
! Causing: javax.servlet.ServletException: org.glassfish.jersey.servlet.ServletContainer-159e366@f02ec575==org.glassfish.jersey.servlet.ServletContainer,1,false
! at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:633) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:395) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:871) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:298) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:741) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61) ~[support-server-0.0.0001.jar:0.0.0001]
! at com.codahale.metrics.jetty9.InstrumentedHandler.doStart(InstrumentedHandler.java:103) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.server.handler.RequestLogHandler.doStart(RequestLogHandler.java:140) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.server.handler.StatisticsHandler.doStart(StatisticsHandler.java:232) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.server.Server.start(Server.java:387) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.server.Server.doStart(Server.java:354) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) ~[support-server-0.0.0001.jar:0.0.0001]
! at io.dropwizard.cli.ServerCommand.run(ServerCommand.java:43) [support-server-0.0.0001.jar:0.0.0001]
! at io.dropwizard.cli.EnvironmentCommand.run(EnvironmentCommand.java:43) [support-server-0.0.0001.jar:0.0.0001]
! at io.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:76) [support-server-0.0.0001.jar:0.0.0001]
! at io.dropwizard.cli.Cli.run(Cli.java:70) [support-server-0.0.0001.jar:0.0.0001]
! at io.dropwizard.Application.run(Application.java:73) [support-server-0.0.0001.jar:0.0.0001]
! at com.car.SupportServerApplication.main(SupportServerApplication.java:51) [support-server-0.0.0001.jar:0.0.0001]
ERROR [2015-09-01 10:36:33,250] io.dropwizard.cli.ServerCommand: Unable to start server, shutting down
! org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.
! [[FATAL] No injection source found for a parameter of type public javax.ws.rs.core.Response com.car.resource.AdminResource.removeUser(com.car.core.User,java.lang.String) at index 0.; source='ResourceMethod{httpMethod=POST, consumedTypes=[application/json], producedTypes=[text/html], suspended=false, suspendTimeout=0, suspendTimeoutUnit=MILLISECONDS, invocable=Invocable{handler=ClassBasedMethodHandler{handlerClass=class com.car.resource.AdminResource, handlerConstructors=[org.glassfish.jersey.server.model.HandlerConstructor@74294c1a]}, definitionMethod=public javax.ws.rs.core.Response com.car.resource.AdminResource.removeUser(com.car.core.User,java.lang.String), parameters=[Parameter [type=class com.car.core.User, source=null, defaultValue=null], Parameter [type=class java.lang.String, source=null, defaultValue=null]], responseType=class javax.ws.rs.core.Response}, nameBindings=[]}']
! at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:554) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:183) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:349) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:346) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.glassfish.jersey.internal.Errors.process(Errors.java:315) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.glassfish.jersey.internal.Errors.process(Errors.java:297) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:255) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:346) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:339) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:362) ~[support-server-0.0.0001.jar:0.0.0001]
! at javax.servlet.GenericServlet.init(GenericServlet.java:244) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:612) ~[support-server-0.0.0001.jar:0.0.0001]
! ... 36 common frames omitted
! Causing: javax.servlet.ServletException: org.glassfish.jersey.servlet.ServletContainer-159e366@f02ec575==org.glassfish.jersey.servlet.ServletContainer,1,false
! at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:633) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:395) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:871) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:298) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:741) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61) ~[support-server-0.0.0001.jar:0.0.0001]
! at com.codahale.metrics.jetty9.InstrumentedHandler.doStart(InstrumentedHandler.java:103) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.server.handler.RequestLogHandler.doStart(RequestLogHandler.java:140) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.server.handler.StatisticsHandler.doStart(StatisticsHandler.java:232) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.server.Server.start(Server.java:387) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.server.Server.doStart(Server.java:354) ~[support-server-0.0.0001.jar:0.0.0001]
! at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) ~[support-server-0.0.0001.jar:0.0.0001]
! at io.dropwizard.cli.ServerCommand.run(ServerCommand.java:43) ~[support-server-0.0.0001.jar:0.0.0001]
! at io.dropwizard.cli.EnvironmentCommand.run(EnvironmentCommand.java:43) [support-server-0.0.0001.jar:0.0.0001]
! at io.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:76) [support-server-0.0.0001.jar:0.0.0001]
! at io.dropwizard.cli.Cli.run(Cli.java:70) [support-server-0.0.0001.jar:0.0.0001]
! at io.dropwizard.Application.run(Application.java:73) [support-server-0.0.0001.jar:0.0.0001]
! at com.car.SupportServerApplication.main(SupportServerApplication.java:51) [support-server-0.0.0001.jar:0.0.0001]
INFO [2015-09-01 10:36:33,259] org.eclipse.jetty.server.ServerConnector: Stopped application@3b582111{HTTP/1.1}{0.0.0.0:8095}
INFO [2015-09-01 10:36:33,269] org.eclipse.jetty.server.ServerConnector: Stopped admin@2899a8db{HTTP/1.1}{0.0.0.0:8096}
Exception in thread "main" javax.servlet.ServletException: org.glassfish.jersey.servlet.ServletContainer-159e366@f02ec575==org.glassfish.jersey.servlet.ServletContainer,1,false
at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:633)
at org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:395)
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:871)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:298)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:741)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
at com.codahale.metrics.jetty9.InstrumentedHandler.doStart(InstrumentedHandler.java:103)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
at org.eclipse.jetty.server.handler.RequestLogHandler.doStart(RequestLogHandler.java:140)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
at org.eclipse.jetty.server.handler.StatisticsHandler.doStart(StatisticsHandler.java:232)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
at org.eclipse.jetty.server.Server.start(Server.java:387)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
at org.eclipse.jetty.server.Server.doStart(Server.java:354)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at io.dropwizard.cli.ServerCommand.run(ServerCommand.java:43)
at io.dropwizard.cli.EnvironmentCommand.run(EnvironmentCommand.java:43)
at io.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:76)
at io.dropwizard.cli.Cli.run(Cli.java:70)
at io.dropwizard.Application.run(Application.java:73)
at com.car.SupportServerApplication.main(SupportServerApplication.java:51)
Caused by: org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.
[[FATAL] No injection source found for a parameter of type public javax.ws.rs.core.Response com.car.resource.AdminResource.removeUser(com.car.core.User,java.lang.String) at index 0.; source='ResourceMethod{httpMethod=POST, consumedTypes=[application/json], producedTypes=[text/html], suspended=false, suspendTimeout=0, suspendTimeoutUnit=MILLISECONDS, invocable=Invocable{handler=ClassBasedMethodHandler{handlerClass=class com.car.resource.AdminResource, handlerConstructors=[org.glassfish.jersey.server.model.HandlerConstructor@74294c1a]}, definitionMethod=public javax.ws.rs.core.Response com.car.resource.AdminResource.removeUser(com.car.core.User,java.lang.String), parameters=[Parameter [type=class com.car.core.User, source=null, defaultValue=null], Parameter [type=class java.lang.String, source=null, defaultValue=null]], responseType=class javax.ws.rs.core.Response}, nameBindings=[]}']
at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:554)
at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:183)
at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:349)
at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:346)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:255)
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:346)
at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:339)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:362)
at javax.servlet.GenericServlet.init(GenericServlet.java:244)
at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:612)
... 36 more
认证服务的实施:
LdapConfiguration ldapConfiguration = configuration.getLdapConfiguration();
Authenticator<BasicCredentials, BasicCredentials> ldapAuthenticator = new CachingAuthenticator<>(
environment.metrics(),
new ResourceAuthenticator(new LdapAuthenticator(ldapConfiguration)),
ldapConfiguration.getCachePolicy());
ldapAuthenticator.authenticate(new BasicCredentials("proxyuser", "test123"));
environment.jersey().register(AuthFactory.binder(new BasicAuthFactory<>(ldapAuthenticator, "realm", BasicCredentials.class)));
答案 0 :(得分:0)
Caused by: org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.
[[FATAL] No injection source found for a parameter of type public javax.ws.rs.core.Response com.car.resource.AdminResource.removeUser(com.car.core.User,java.lang.String) at index 0.; source='ResourceMethod{httpMethod=POST, consumedTypes=[application/json], producedTypes=[text/html], suspended=false, suspendTimeout=0, suspendTimeoutUnit=MILLISECONDS, invocable=Invocable{handler=ClassBasedMethodHandler{handlerClass=class com.car.resource.AdminResource, handlerConstructors=[org.glassfish.jersey.server.model.HandlerConstructor@74294c1a]}, definitionMethod=public javax.ws.rs.core.Response com.car.resource.AdminResource.removeUser(com.car.core.User,java.lang.String), parameters=[Parameter [type=class com.car.core.User, source=null, defaultValue=null], Parameter [type=class java.lang.String, source=null, defaultValue=null]], responseType=class javax.ws.rs.core.Response}, nameBindings=[]}']
您很可能还没有配置身份验证机制。例如
env.jersey().register(AuthFactory.binder(
new BasicAuthFactory<SimplePrincipal>(
authenticator,
"Example Realm",
SimplePrincipal.class)));
这是导致错误的原因。在启动时,Jersey会执行所谓的模型验证,以验证所有资源模型都是正确的#34;。这主要是为了避免运行时出现任何问题。
Jersey看到两个未知(或未注释)类型对象的参数,如果它只是一个,这不是问题,因为通常有一个实体主体对象。对于其他人,他们被注释识别。对于自定义注释,例如removeUser
,需要配置自定义@Auth
。可以在ValueFactoryProvider/InjectionResolver
类中找到@Auth
注入的Dropwizard实现here。 AuthFactory.binder
(如上所示)是提供商的注册方式。
另见: