有两台linux服务器A、B
系统版本都是 Red Hat Enterprise Linux Server release 6.0 (Santiago)
JDK版本都是 1.6.0_29
在A端发布一个RMI服务,配置如下
<bean factory-method="setProperty" class="java.lang.System" lazy-init="false">
<constructor-arg value="java.rmi.dgc.leaseValue"/>
<constructor-arg value="300000"/>
</bean>
<bean factory-method="setProperty" class="java.lang.System" lazy-init="false">
<constructor-arg value="java.rmi.dgc.gcInterval"/>
<constructor-arg value="900000"/>
</bean>
<!--接收数据服务(下层模块提交的数据)-->
<bean id="eventProcessor" class="com.dataservice.EventProcessorImpl"/>
<bean id="rmiEventProcess"
class="org.springframework.remoting.rmi.RmiServiceExporter"> <property name="serviceName" value="dataservice/eventProcessor" />
<property name="service" ref="eventProcessor" />
<property name="serviceInterface" value="com.dataservice.EventProcessor" />
<property name="registryPort" value="${registryPort}"/>
<property name="servicePort" value="${registryPort}"/>
B端为客户端,配置如下
<bean id="rmiEventProcessorClient" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
<property name="serviceUrl" value="${targetAddr}" />
<property name="serviceInterface"
value="com.dataservice.EventProcessor" />
<property name="refreshStubOnConnectFailure" value="true"></property>
</bean>
情况是这样的,B端在调用A端发布的服务时,间歇性的出现如下异常。
异常信息:error marshalling arguments; nested exception is:
java.net.SocketException: Broken pipe
java.rmi.MarshalException: error marshalling arguments; nested exception is:
java.net.SocketException: Broken pipe
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:138)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:178)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:132)
at $Proxy0.invoke(Unknown Source)
at org.springframework.remoting.rmi.RmiClientInterceptor.doInvoke(RmiClientInterceptor.java:398)
at org.springframework.remoting.rmi.RmiClientInterceptor.doInvoke(RmiClientInterceptor.java:344)
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 $Proxy1.handleEvent(Unknown Source)
at com.dataservice.EventSenderImpl.handleEvent(EventSenderImpl.java:220)
at com.dataservice.EventSenderImpl.sendEventTask(EventSenderImpl.java:191)
at com.dataservice.EventSenderImpl.access$0(EventSenderImpl.java:173)
at com.dataservice.EventSenderImpl$ResSendTask.run(EventSenderImpl.java:166)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:204)
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.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
at java.io.BufferedOutputStream.write(BufferedOutputStream.java:109)
at java.io.ObjectOutputStream$BlockDataOutputStream.drain(ObjectOutputStream.java:1847)
at java.io.ObjectOutputStream$BlockDataOutputStream.writeByte(ObjectOutputStream.java:1885)
at java.io.ObjectOutputStream.writeFatalException(ObjectOutputStream.java:1546)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:333)
at sun.rmi.server.UnicastRef.marshalValue(UnicastRef.java:274)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
... 22 more
补充:相同的程序,放在linux版本相同,JDK版本相同的服务器C去调用A不会出现以上问题,B、和C的防火墙策略是相同的,防火墙关了也会有这个问题,就算把服务端部署在B,B内部调用也会间歇性出现该问题。
奔溃了,搞不定啊,求解。。。。