简体   繁体   English

在 APIHealthCheck 上获取 Dropwizard 客户端和 Jersey/HTTP I/O 错误

[英]Getting Dropwizard Client And Jersey/HTTP I/O Error on APIHealthCheck

I am currently doing an assignment for a class that requires me to develop a Maven project on eclipse that utilizes Dropwizard Authentication and Jersey HTTP. I am currently doing an assignment for a class that requires me to develop a Maven project on eclipse that utilizes Dropwizard Authentication and Jersey HTTP. I looked everywhere on the internet for a solution, including stackoverflow.我在互联网上到处寻找解决方案,包括 stackoverflow。 When I run the server on my local machine, it seems to run fine.当我在本地机器上运行服务器时,它似乎运行良好。 But when I do the simple health check on http://localhost:8080/status, it gives me this error message.但是当我对 http://localhost:8080/status 进行简单的健康检查时,它给了我这个错误消息。

127.0.0.1 - - [04/Jun/2021:21:25:52 +0000] "GET /gameusers HTTP/1.1" 404 43 "-" "GameAuthApplication (GameUserRESTClient)" 17
[0:0:0:0:0:0:0:1] - - [04/Jun/2021:21:25:52 +0000] "GET /status HTTP/1.1" 200 21845 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36" 143
ERROR [2021-06-04 21:25:52,503] org.glassfish.jersey.server.ServerRuntime$Responder: An I/O error has occurred while writing a response message entity to the container output stream.
! com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: java.util.Collections$UnmodifiableMap$UnmodifiableEntrySet[0]->java.util.Collections$UnmodifiableMap$UnmodifiableEntrySet$UnmodifiableEntry["APIHealthCheck"]->com.codahale.metrics.health.HealthCheck$Result["error"]->javax.ws.rs.ProcessingException["cause"]->com.fasterxml.jackson.databind.exc.MismatchedInputException["location"]->com.fasterxml.jackson.core.JsonLocation["sourceRef"])
! at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:77)
! at com.fasterxml.jackson.databind.SerializerProvider.reportBadDefinition(SerializerProvider.java:1276)
! at com.fasterxml.jackson.databind.DatabindContext.reportBadDefinition(DatabindContext.java:400)
! at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.failForEmpty(UnknownSerializer.java:71)
! at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.serialize(UnknownSerializer.java:33)
! at com.fasterxml.jackson.module.blackbird.ser.ObjectPropertyWriter.serializeAsField(ObjectPropertyWriter.java:95)
! at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:770)
! at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178)
! at com.fasterxml.jackson.module.blackbird.ser.ObjectPropertyWriter.serializeAsField(ObjectPropertyWriter.java:95)
! at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:770)
! at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178)
! at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:728)
! at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:770)
! at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178)
! at com.fasterxml.jackson.module.blackbird.ser.ObjectPropertyWriter.serializeAsField(ObjectPropertyWriter.java:95)
! at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:770)
! at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178)
! at com.fasterxml.jackson.databind.ser.impl.MapEntrySerializer.serializeDynamic(MapEntrySerializer.java:407)
! at com.fasterxml.jackson.databind.ser.impl.MapEntrySerializer.serialize(MapEntrySerializer.java:341)
! at com.fasterxml.jackson.databind.ser.impl.MapEntrySerializer.serialize(MapEntrySerializer.java:24)
! at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:145)
! at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.java:107)
! at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.java:25)
! at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:480)
! at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:400)
! at com.fasterxml.jackson.databind.ObjectWriter$Prefetch.serialize(ObjectWriter.java:1510)
! at com.fasterxml.jackson.databind.ObjectWriter.writeValue(ObjectWriter.java:1006)
! at com.fasterxml.jackson.jaxrs.base.ProviderBase.writeTo(ProviderBase.java:626)
! at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.invokeWriteTo(WriterInterceptorExecutor.java:242)
! at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:227)
! at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:139)
! at io.dropwizard.jersey.errors.EofExceptionWriterInterceptor.aroundWriteTo(EofExceptionWriterInterceptor.java:39)
! at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:139)
! at org.glassfish.jersey.server.internal.JsonWithPaddingInterceptor.aroundWriteTo(JsonWithPaddingInterceptor.java:85)
! at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:139)
! at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundWriteTo(MappableExceptionWrapperInterceptor.java:61)
! ... 54 common frames omitted
! Causing: org.glassfish.jersey.server.internal.process.MappableException: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: java.util.Collections$UnmodifiableMap$UnmodifiableEntrySet[0]->java.util.Collections$UnmodifiableMap$UnmodifiableEntrySet$UnmodifiableEntry["APIHealthCheck"]->com.codahale.metrics.health.HealthCheck$Result["error"]->javax.ws.rs.ProcessingException["cause"]->com.fasterxml.jackson.databind.exc.MismatchedInputException["location"]->com.fasterxml.jackson.core.JsonLocation["sourceRef"])
! at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundWriteTo(MappableExceptionWrapperInterceptor.java:67)
! at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:139)
! at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1116)
! at org.glassfish.jersey.server.ServerRuntime$Responder.writeResponse(ServerRuntime.java:635)
! at org.glassfish.jersey.server.ServerRuntime$Responder.processResponse(ServerRuntime.java:373)
! at org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.java:363)
! at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:258)
! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:248)
! at org.glassfish.jersey.internal.Errors$1.call(Errors.java:244)
! at org.glassfish.jersey.internal.Errors.process(Errors.java:292)
! at org.glassfish.jersey.internal.Errors.process(Errors.java:274)
! at org.glassfish.jersey.internal.Errors.process(Errors.java:244)
! at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:265)
! at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:234)
! at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:680)
! at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:394)
! at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:346)
! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:366)
! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:319)
! at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:205)
! at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:791)
! at org.eclipse.jetty.servlet.ServletHandler$ChainEnd.doFilter(ServletHandler.java:1626)
! at io.dropwizard.servlets.ThreadNameFilter.doFilter(ThreadNameFilter.java:35)
! at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193)
! at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1601)
! at io.dropwizard.jersey.filter.AllowedMethodsFilter.handle(AllowedMethodsFilter.java:47)
! at io.dropwizard.jersey.filter.AllowedMethodsFilter.doFilter(AllowedMethodsFilter.java:41)
! at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193)
! at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1601)
! at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:548)
! at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
! at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1435)
! at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
! at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:501)
! at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
! at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1350)
! at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
! at com.codahale.metrics.jetty9.InstrumentedHandler.handle(InstrumentedHandler.java:313)
! at io.dropwizard.jetty.RoutingHandler.handle(RoutingHandler.java:52)
! at org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:763)
! at org.eclipse.jetty.server.handler.RequestLogHandler.handle(RequestLogHandler.java:54)
! at org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:179)
! at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
! at org.eclipse.jetty.server.Server.handle(Server.java:516)
! at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:388)
! at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:633)
! at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:380)
! at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:277)
! at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
! at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
! at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
! at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:882)
! at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1036)
! at java.base/java.lang.Thread.run(Thread.java:832)

I tried following the tutorial verbatim on https://howtodoinjava.com/dropwizard/dropwizard-basic-auth-security-example/我尝试逐字按照 https://howtodoinjava.com/dropwizard/dropwizard-basic-auth-security-example/上的教程进行操作

The code is in a git repo... https://github.com/RedJaVa68/GameAuth.git代码在 git 回购... https://github.com/RedJaVa68/GameAuth.git

This is a serialization issue.这是一个序列化问题。 As per the github repo that you shared there doesn't seem to be a endpoint associated with /gameusers path.根据您共享的 github 存储库,似乎没有与/gameusers路径关联的端点。 But its being called in the health check callback.但它在健康检查回调中被调用。 So the call is failing and its not able to deserialize error response into ArrayList.所以调用失败并且它无法将错误响应反序列化为 ArrayList。 In GameUserRESTController.java you need to add the path as follows:GameUserRESTController.java需要添加如下路径:

@Produces({"application/json"})
@Path("/gameusers") // this might be missing
public class GameUserRESTController {

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM