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

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

我目前正在为一个课程做作业,该课程要求我在 eclipse 上开发一个利用 Dropwizard 身份验证和 Jersey HTTP 的 Maven 项目。我在互联网上到处寻找解决方案,包括 stackoverflow。当我在本地机器上运行服务器时,它似乎运行良好。但是当我对 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)

我尝试在 https://howtodoinjava.com/dropwizard/dropwizard-basic-auth-security-example/

上逐字学习教程

代码在 git 仓库中... https://github.com/RedJaVa68/GameAuth.git

解决方法

这是一个序列化问题。根据您共享的 github 存储库,似乎没有与 /gameusers 路径关联的端点。但它在健康检查回调中被调用。因此调用失败并且无法将错误响应反序列化为 ArrayList。在 GameUserRESTController.java 中,您需要添加如下路径:

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?