现在服务端加了超时设置:
<bean id="registry" class="org.springframework.remoting.rmi.RmiRegistryFactoryBean">
<property name="port" value="8088"/>
</bean>
<bean id="serviceExporter" class="org.springframework.remoting.rmi.RmiServiceExporter">
<property name="serviceName" value="ParPriceService"></property>
<property name="service" ref="parPriceService"></property>
<property name="serviceInterface"
value="com.qunar.service.ParPriceService"></property>
<!-- <property name="registryPort" value="8088"></property>
<property name="servicePort" value="8088"></property> -->
<property name="registry" ref="registry"></property>
<property name="clientSocketFactory" ref="rmiClientSocketFactory" />
<property name="serverSocketFactory" ref="rmiServerSocketFactory" />
</bean>
<bean id="rmiClientSocketFactory" class="com.qunar.rmi.RMICustomClientSocketFactory">
<property name="timeout" value="5000"></property><!--这里配置的是client的读超时-->
</bean>
<bean id="rmiServerSocketFactory" class="com.qunar.rmi.RMICustomServerSocketFactory">
<property name="timeout" value="5000"></property> <!--这里配置的是server监听请求超时设置,5S内无请求server端会抛异常-->
</bean>客户端配置了自动重连
<bean id="rmiClientSocketFactory" class="com.qunar.rmi.RMICustomClientSocketFactory">
<property name="timeout" value="5000"></property>
</bean>
<bean id="rmiParPriceService" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
<property name="serviceUrl" value="rmi://192.168.0.95:8088/ParPriceService" />
<property name="serviceInterface"
value="com.qunar.service.ParPriceService"/>
<property name="refreshStubOnConnectFailure" value="true"></property>
<property name="lookupStubOnStartup" value="false"></property>
<property name="registryClientSocketFactory" ref="rmiClientSocketFactory"></property>
</bean>但是访问到一定的时间之后还是会报错
<bean id="registry" class="org.springframework.remoting.rmi.RmiRegistryFactoryBean">
<property name="port" value="8088"/>
</bean>
<bean id="serviceExporter" class="org.springframework.remoting.rmi.RmiServiceExporter">
<property name="serviceName" value="ParPriceService"></property>
<property name="service" ref="parPriceService"></property>
<property name="serviceInterface"
value="com.qunar.service.ParPriceService"></property>
<!-- <property name="registryPort" value="8088"></property>
<property name="servicePort" value="8088"></property> -->
<property name="registry" ref="registry"></property>
<property name="clientSocketFactory" ref="rmiClientSocketFactory" />
<property name="serverSocketFactory" ref="rmiServerSocketFactory" />
</bean>
<bean id="rmiClientSocketFactory" class="com.qunar.rmi.RMICustomClientSocketFactory">
<property name="timeout" value="5000"></property><!--这里配置的是client的读超时-->
</bean>
<bean id="rmiServerSocketFactory" class="com.qunar.rmi.RMICustomServerSocketFactory">
<property name="timeout" value="5000"></property> <!--这里配置的是server监听请求超时设置,5S内无请求server端会抛异常-->
</bean>客户端配置了自动重连
<bean id="rmiClientSocketFactory" class="com.qunar.rmi.RMICustomClientSocketFactory">
<property name="timeout" value="5000"></property>
</bean>
<bean id="rmiParPriceService" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
<property name="serviceUrl" value="rmi://192.168.0.95:8088/ParPriceService" />
<property name="serviceInterface"
value="com.qunar.service.ParPriceService"/>
<property name="refreshStubOnConnectFailure" value="true"></property>
<property name="lookupStubOnStartup" value="false"></property>
<property name="registryClientSocketFactory" ref="rmiClientSocketFactory"></property>
</bean>但是访问到一定的时间之后还是会报错
解决方案 »
- 哪位大侠可以推荐几本JavaEE项目开发实战书籍?
- 谁知道问题所在?
- 如何获取跳转页面的参数?
- 对web中应用j2ee的理解
- JAVA菜鸟求救:有关JAVA 2 Runtime Environment版本的问题!
- 一个etmvc数据库操作异常
- 请问学习EJB需要学习实体bean和消息bean吗?
- JB8中创建一个EntityBean,但是编译的时候为什么不产生jar文件
- jbuilder+weblogic进行开发,加入打印程序,为什么服务器会停止?高手帮忙!!
- Mybatis+SpringMVC 封装查找到的实体时java.lang.NoSuchMethodException: com.kker.dao.AgentDa
- 求助 Error creating bean with name 'sessionFactory' 急急急有没有高手帮忙解决哈
- 大家所在公司怎么搭建的java开发,测试,生产环境的?
<bean id="registry" class="org.springframework.remoting.rmi.RmiRegistryFactoryBean">
<property name="port" value="8088"/>
</bean>
<bean id="serviceExporter" class="org.springframework.remoting.rmi.RmiServiceExporter">
<property name="serviceName" value="ParPriceService"></property>
<property name="service" ref="parPriceService"></property>
<property name="serviceInterface"
value="com.qunar.service.ParPriceService"></property>
<!-- <property name="registryPort" value="8088"></property>
<property name="servicePort" value="8088"></property> -->
<property name="registry" ref="registry"></property>
<property name="clientSocketFactory" ref="rmiClientSocketFactory" />
<property name="serverSocketFactory" ref="rmiServerSocketFactory" />
</bean>
<bean id="rmiClientSocketFactory" class="com.qunar.rmi.RMICustomClientSocketFactory">
<property name="timeout" value="5000"></property><!--这里配置的是client的读超时-->
</bean>
<bean id="rmiServerSocketFactory" class="com.qunar.rmi.RMICustomServerSocketFactory">
<property name="timeout" value="5000"></property> <!--这里配置的是server监听请求超时设置,5S内无请求server端会抛异常-->
</bean>
org.springframework.remoting.RemoteAccessException: Could not access remote service [rmi://192.168.0.95:8088/ParPriceService]; nested exception is java.rmi.UnmarshalException: Error unmarshaling return header; nested exception is:
java.net.SocketTimeoutException: Read timed out
at org.springframework.remoting.rmi.RmiClientInterceptorUtils.convertRmiAccessException(RmiClientInterceptorUtils.java:193)
at org.springframework.remoting.rmi.RmiClientInterceptor.doInvoke(RmiClientInterceptor.java:347)
at org.springframework.remoting.rmi.RmiClientInterceptor.invoke(RmiClientInterceptor.java:259)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at com.sun.proxy.$Proxy0.getParPrices(Unknown Source)
at test.Test$1.run(Test.java:75)
at java.lang.Thread.run(Unknown Source)
Caused by: java.rmi.UnmarshalException: Error unmarshaling return header; nested exception is:
java.net.SocketTimeoutException: Read timed out
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(Unknown Source)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(Unknown Source)
at com.sun.proxy.$Proxy1.invoke(Unknown Source)
at org.springframework.remoting.rmi.RmiClientInterceptor.doInvoke(RmiClientInterceptor.java:398)
at org.springframework.remoting.rmi.RmiClientInterceptor.doInvoke(RmiClientInterceptor.java:344)
... 6 more
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at java.io.DataInputStream.readByte(Unknown Source)
java.net.SocketTimeoutException: Read timed out
at org.springframework.remoting.rmi.RmiClientInterceptorUtils.convertRmiAccessException(RmiClientInterceptorUtils.java:193)
at org.springframework.remoting.rmi.RmiClientInterceptor.doInvoke(RmiClientInterceptor.java:347)
at org.springframework.remoting.rmi.RmiClientInterceptor.invoke(RmiClientInterceptor.java:259)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at com.sun.proxy.$Proxy0.getParPrices(Unknown Source)
at test.Test$1.run(Test.java:75)
at java.lang.Thread.run(Unknown Source)
Caused by: java.rmi.UnmarshalException: Error unmarshaling return header; nested exception is:
java.net.SocketTimeoutException: Read timed out
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(Unknown Source)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(Unknown Source)
at com.sun.proxy.$Proxy1.invoke(Unknown Source)
at org.springframework.remoting.rmi.RmiClientInterceptor.doInvoke(RmiClientInterceptor.java:398)
at org.springframework.remoting.rmi.RmiClientInterceptor.doInvoke(RmiClientInterceptor.java:344)
... 6 more
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at java.io.DataInputStream.readByte(Unknown Source)