我有两个运行 local 的应用程序,一个是JBoss,另一个是在tomcat上运行。 Jboss应用程序是遗留应用程序,我在其中进行了代码更改以将流量路由到tomcat服务器。我想在我们的QA盒上部署之前先在本地测试这个代码更改。如果请求是某种类型的JBoss应用程序构建HttpClient
并使用适当的请求,标题等对tomcat应用程序进行POST调用,那么我已经打印了这个,所以这里没有问题。现在在我的tomcat应用程序的控制台日志中,我只看到SocketTimeoutException
下面的错误,所以请求立即死在某处。我迷失在这里并且不知道如何进一步调试
我尝试过的事情 1.我多次重启应用程序 2.增加套接字超时和连接超时等 3.在调试模式下启动JBoss应用程序并确保在实际路由到tomcat之前发生请求,标头,http客户端配置等。
2016-05-06 14:36:53,920 ERROR [http-nio-8080-exec-2] - 87d141f302e74 - ygpdY8VQsu -
util.ExceptionHandler - INTERNAL_SERVICE_ERROR_java.net.SocketTimeoutException_org.apache.tomcat.util.net.NioBlockingSelector_read_202
java.net.SocketTimeoutException
at org.apache.tomcat.util.net.NioBlockingSelector.read(NioBlockingSelector.java:202)
at org.apache.tomcat.util.net.NioSelectorPool.read(NioSelectorPool.java:251)
at org.apache.tomcat.util.net.NioSelectorPool.read(NioSelectorPool.java:232)
at org.apache.coyote.http11.InternalNioInputBuffer.fill(InternalNioInputBuffer.java:133)
at org.apache.coyote.http11.InternalNioInputBuffer$SocketInputBuffer.doRead(InternalNioInputBuffer.java:177)
at org.apache.coyote.http11.filters.IdentityInputFilter.doRead(IdentityInputFilter.java:110)
at org.apache.coyote.http11.AbstractInputBuffer.doRead(AbstractInputBuffer.java:416)
at org.apache.coyote.Request.doRead(Request.java:460)
at org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:338)
at org.apache.tomcat.util.buf.ByteChunk.substract(ByteChunk.java:395)
at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:363)
at org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:190)
at com.fasterxml.jackson.core.json.ByteSourceJsonBootstrapper.ensureLoaded(ByteSourceJsonBootstrapper.java:505)
at com.fasterxml.jackson.core.json.ByteSourceJsonBootstrapper.detectEncoding(ByteSourceJsonBootstrapper.java:129)
at com.fasterxml.jackson.core.json.ByteSourceJsonBootstrapper.constructParser(ByteSourceJsonBootstrapper.java:226)
at com.fasterxml.jackson.core.JsonFactory._createJsonParser(JsonFactory.java:1191)
at com.fasterxml.jackson.core.JsonFactory._createParser(JsonFactory.java:1182)
at com.fasterxml.jackson.core.JsonFactory.createJsonParser(JsonFactory.java:831)
at com.fasterxml.jackson.core.JsonFactory.createParser(JsonFactory.java:671)
at com.fasterxml.jackson.jaxrs.base.ProviderBase._createParser(ProviderBase.java:575)
at org.jboss.resteasy.plugins.providers.jackson.ResteasyJackson2Provider.readFrom(ResteasyJackson2Provider.java:111)
at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.readFrom(AbstractReaderInterceptorContext.java:59)
at org.jboss.resteasy.core.interception.ServerReaderInterceptorContext.readFrom(ServerReaderInterceptorContext.java:62)
at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:51)
经过进一步调试后,我发现错误发生在context.proceed();
行的tomcat服务器读取拦截器
public class DecoratedReaderInterceptor implements ReaderInterceptor {
@Override
public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException {
boolean validate = shouldValidateResource(context);
Object obj = context.proceed();
if (obj instanceof Resource) {
processResource((Resource) obj, validate);
} else if (obj instanceof Resource[]) {
for (Resource resource : (Resource[]) obj) {
processResource(resource, validate);
}
}
return obj;
}
}
找到了答案,我感到尴尬。在JBoss服务器中,我添加了一个调试语句,用于读取流以输出请求,现在流已经被读取,tomcat服务器没有任何消耗。因此SocketTimeoutException