当前位置: 代码迷 >> 高性能WEB开发 >> java.rmi.ConnectIOException: error during JRMP connection establishment,该怎么处理
  详细解决方案

java.rmi.ConnectIOException: error during JRMP connection establishment,该怎么处理

热度:1373   发布时间:2014-02-27 01:51:42.0
java.rmi.ConnectIOException: error during JRMP connection establishment
描述:我有个类代码如下,在main方法中调用,每10秒钟调用一次,开始运行没问题,运行一天左右就报错
public void excuteAlarm() throws ParserConfigurationException,
SAXException, IOException {
setCtx(new FileSystemXmlApplicationContext("classpath:applicationContext.xml"));
setEntityManagerFactory((EntityManagerFactory) ctx.getBean("entityManagerFactory"));
EntityManager em = entityManagerFactory.createEntityManager();
// 取得监测数据
String COUNT_ALL = "。。。。。。。。。 ";
 
int count = ((Number) em.createNativeQuery(COUNT_ALL).getResultList().get(0)).intValue();
 
if (em.isOpen()) {
em.close();
}
EntityManagerFactoryUtils.closeEntityManager(em);
 
System.out.println("要处理的所有对象总数" + count);
 
List<RmiService> rmiServiceList =getPropertyValue();//取到服务的个数

if(rmiServiceList == null || rmiServiceList.size() == 0){
logger.warn("找不到运行状态的服务器");
}else{
int ServiceCount = rmiServiceList.size();
int eachService = count / ServiceCount;
for (int i = 0; i < ServiceCount; i++) {
int[] wellData = { i*eachService+1, (i+1)*eachService };
if(i == (ServiceCount - 1)){
wellData[0] = i*eachService+1;
wellData[1] = count;
}
String[] ThreadPoolParam = { "1", "4", "4", "1" };

AlarmClientThread  alarmClientThread = new AlarmClientThread(ThreadPoolParam,wellData,rmiServiceList.get(i).getUrl());
Thread thread =new Thread(alarmClientThread);
logger.info("转换从"+wellData[0]+"到"+wellData[1]);
thread.start();
}
 
}
}


报错如下各位大神求解!
2013-12-04 14:45:23,158 [Thread-2] ERROR [com.cnpc.a11.A11RealTimeDataService.se
rvice.thread.AlarmClientThread] - error
java.rmi.ConnectIOException: error during JRMP connection establishment; nested
exception is:
        java.net.SocketTimeoutException: Read timed out
        at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:304
)
        at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
        at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:340)
        at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
        at java.rmi.Naming.lookup(Naming.java:101)
        at com.cnpc.a11.A11RealTimeDataService.service.thread.AlarmClientThread.
run(AlarmClientThread.java:28)
        at java.lang.Thread.run(Thread.java:724)
Caused by: java.net.SocketTimeoutException: Read timed out
        at java.net.SocketInputStream.socketRead0(Native Method)
        at java.net.SocketInputStream.read(SocketInputStream.java:150)
        at java.net.SocketInputStream.read(SocketInputStream.java:121)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:254)
        at java.io.DataInputStream.readByte(DataInputStream.java:265)
        at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:246
)
        ... 6 more连接超过了1024
  相关解决方案