java org.springframework.remoting.RemoteAccessException:从另一个线程启动任务时发生无法访问 HTTP 调用程序远程服务
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13007331/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
org.springframework.remoting.RemoteAccessException: Could not access HTTP invoker remote service occurs when starting tasks from anbother thread
提问by Julia
I have spring application with JavaFX client, and I get this exception when ever come method is called which runs in another thread (for background tasks) - which is not the main JavaFx thread.
我有 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.AccessRightsBatchDialogLocal4.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
The last change I made, and I suspect, a cause of this - because I need user info from HTTP session, in each service proxy , I am passing this httpInvokerRequestExecutor bean:
我所做的最后一次更改,我怀疑,这是一个原因 - 因为我需要来自 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>
With methods which run in main thread, this never seems to happen.
对于在主线程中运行的方法,这似乎永远不会发生。
All ideas on caused and possible solutions are very welcomed.
非常欢迎有关原因和可能解决方案的所有想法。
采纳答案by Wilhelm Kleu
Inrease the read timeout for httpInvokerRequestExecuter
. The default is a minute. You can either increase it or set to 0 which means it will never timeout (probably not a good idea but good for a test).
增加读取超时httpInvokerRequestExecuter
。默认值为一分钟。您可以增加它或设置为 0,这意味着它永远不会超时(可能不是一个好主意,但对测试很有用)。
Bean definition to remove readTimeout (or set it to applicable amount):
删除 readTimeout 的 Bean 定义(或将其设置为适用的数量):
<bean id="httpInvokerRequestExecuter" class="org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecuto??r" >
<property name="readTimeout" value="0" />
</bean>