3

我有带有 JavaFX 客户端的 spring 应用程序,当调用在另一个线程(用于后台任务)中运行的方法时,我得到了这个异常——这不是主要的 JavaFx 线程。

org.springframework.remoting.RemoteAccessException: Could not access HTTP invoker remote service at [http://localhost:8080/server/service/security/UserGroupService]; 
 nested exception is java.net.SocketTimeoutException: Read timed out
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.convertHttpInvokerAccessException(HttpInvokerClientInterceptor.java:211)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.invoke(HttpInvokerClientInterceptor.java:144)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy63.batchJobSetAccessRightsToConsultant(Unknown Source)
at client.view.control.reporting.AccessRightsBatchDialog$1Local$744.invoke$(AccessRightsBatchDialog.fx:374)
at com.sun.javafx.functions.Function1.invoke(Function1.java:44)
at com.sun.javafx.functions.Function1.invoke$(Function1.java:38)
at client.async.AsyncTask.taskRun(AsyncTask.fx:71)
at client.async.AsyncTaskHelper.run(AsyncTaskHelper.java:32)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
  Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
at java.io.BufferedInputStream.read(BufferedInputStream.java:237)
at org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:78)
at org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:106)
at org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1116)
at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.readLine(MultiThreadedHttpConnectionManager.java:1413)
at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1973)
at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1735)
at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1098)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
at org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor.executePostMethod(CommonsHttpInvokerRequestExecutor.java:195)
at org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor.doExecuteRequest(CommonsHttpInvokerRequestExecutor.java:129)
at org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor.executeRequest(AbstractHttpInvokerRequestExecutor.java:136)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.executeRequest(HttpInvokerClientInterceptor.java:191)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.executeRequest(HttpInvokerClientInterceptor.java:173)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.invoke(HttpInvokerClientInterceptor.java:141)
... 11 more

我所做的最后一次更改,我怀疑,这是一个原因 - 因为我需要来自 HTTP 会话的用户信息,在每个服务代理中,我正在传递这个 httpInvokerRequestExecutor bean:

<bean id="httpInvokerRequestExecuter" class="org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor" >

for example:

<bean id="testServiceProxy"
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
    <property name="serviceUrl" value="${remoteUrl}/service/test/TestService" />
    <property name="serviceInterface"
        value="common.service.test.TestService" />
    <property name="httpInvokerRequestExecutor" ref="httpInvokerRequestExecuter" />
</bean>

对于在主线程中运行的方法,这似乎永远不会发生。

所有关于原因和可能解决方案的想法都非常受欢迎。

4

1 回答 1

2

增加 的读取超时httpInvokerRequestExecuter。默认值为一分钟。您可以增加它或设置为 0,这意味着它永远不会超时(可能不是一个好主意,但对测试很有用)。

删除 readTimeout 的 Bean 定义(或将其设置为适用的数量):

<bean id="httpInvokerRequestExecuter" class="org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecuto‌​r" > 
     <property name="readTimeout" value="0" /> 
</bean> 
于 2012-10-22T08:23:09.570 回答