ICE in JAVA. exception in `Ice.Thread Pool.Client'

ntsjunntsjun Jun SuOrganization: self employedProject: webapp written in java invoke .net programMember
Hi:
When I study ICE, found some errors. anybody can help me?thanks.
I implemented a server in C#,implemented a client in java.
In client, there is a thread named 'StationWatcher' execute the run method every 10 seconds:
@Override
public void run() {
  ArrayList<Station> temp = new ArrayList<Station>();
 for (Station s : Config.getAllStation()) {
   int[] errCircuits = isNormal(s);
   if (errCircuits.length > 0) {
    temp.add(s);
   }
 }
}
private int[] isNormal(Station s) {
  IntBuffer temp = IntBuffer.allocate(s.getAllCircuit().size());
  for (Circuit c : s.getAllCircuit()) {
   if (c.isHasStealProof()) {
    String sProof = DBCommProxy.getInstance().getValue(
    c.getVariable(VariableTemplete.StealProof));


    if (sProof != null) {
     if (!sProof.equals("1")) {
      temp.put(c.getID());
     }
    }
  }
 }
 temp.flip();
 int[] rtn = new int[temp.limit()];
 temp.get(rtn);
 return rtn;
}
The DBCommProxy is a class extends from Ice.ObjectPrx. when DBCommProxy.getInstance().getValue catch any exception , it will stop the thread StationWatcher.

when the server is closed, client console will throw the follow exception continuously 。buy when the server is closed, the exception will raise in DBCommProxy.getInstance().getValue, and the StationWatcher thread will be stoped. but why It seems that the ice client is try to connect the server again and again.

!! 10-7-23 22:04:35:522 error: Ice.ThreadPool.Client-0: exception in `Ice.Thread
Pool.Client':
Ice.SocketException
error = 0
at IceInternal.ThreadPoolWorkQueue.postMessage(ThreadPoolWorkQueue.java:
166)
at IceInternal.ThreadPoolWorkQueue.message(ThreadPoolWorkQueue.java:114)
at IceInternal.ThreadPool.run(ThreadPool.java:302)
at IceInternal.ThreadPool.access$300(ThreadPool.java:12)
at IceInternal.ThreadPool$EventHandlerThread.run(ThreadPool.java:643)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.nio.channels.ClosedChannelException
at sun.nio.ch.SocketChannelImpl.ensureWriteOpen(SocketChannelImpl.java:1
26)
at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:324)
at sun.nio.ch.SinkChannelImpl.write(SinkChannelImpl.java:96)
at IceInternal.ThreadPoolWorkQueue.postMessage(ThreadPoolWorkQueue.java:
162)
... 5 more
event handler: work queue
!! 10-7-23 22:04:35:537 error: Ice.ThreadPool.Client-0: exception in `Ice.Thread
Pool.Client':
Ice.SocketException
error = 0
at IceInternal.ThreadPoolWorkQueue.postMessage(ThreadPoolWorkQueue.java:
166)
at IceInternal.ThreadPoolWorkQueue.message(ThreadPoolWorkQueue.java:114)
at IceInternal.ThreadPool.run(ThreadPool.java:302)
at IceInternal.ThreadPool.access$300(ThreadPool.java:12)
at IceInternal.ThreadPool$EventHandlerThread.run(ThreadPool.java:643)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.nio.channels.ClosedChannelException
at sun.nio.ch.SocketChannelImpl.ensureWriteOpen(SocketChannelImpl.java:1
26)

is there some wrong in client JAVA code ?

Comments

  • mesmes CaliforniaMark SpruiellOrganization: ZeroC, Inc.Project: Ice DeveloperAdministrators, ZeroC Staff ZeroC Staff
    Please provide the following information:
    • Ice version
    • Java JDK version
    • Operating system version
    Also, is your client calling Thread.interrupt()? Do you have a small Java example that demonstrates the problem?

    Regards,
    Mark
  • ntsjunntsjun Jun SuOrganization: self employedProject: webapp written in java invoke .net programMember
    mes wrote: »
    Please provide the following information:
    • Ice version
    • Java JDK version
    • Operating system version
    Also, is your client calling Thread.interrupt()? Do you have a small Java example that demonstrates the problem?

    Regards,
    Mark
    Thanks mes !
    The enviroment is:
    • ICE version:3.4.1
    • JDK Version:build 16.0-b13
    • OS:Windows XP SP3
    I wrote a sample demonstrates the problem( see attachement). finally ,these program will be used in a webapp , web server is tomcat 6 .
    DBCommProxy class is responsible for communicate by ICE. StationWatcher is a scan thread. while DBCommProxy established connection with ICE server, it will launch the StationWatcher thread.

    thanks again!
  • ntsjunntsjun Jun SuOrganization: self employedProject: webapp written in java invoke .net programMember
    any body can help me ?

    any body can help me ?
  • mesmes CaliforniaMark SpruiellOrganization: ZeroC, Inc.Project: Ice DeveloperAdministrators, ZeroC Staff ZeroC Staff
    The problem is caused by this line:

    future.cancel(true);

    When you pass true to the cancel method, you are allowing it to interrupt a thread if necessary. This interrupt causes a socket used internally by the Ice thread pool to be closed and results in the infinite loop that follows.

    Change the argument to false and everything works as expected. As a general rule, Ice for Java does not work well in the presence of thread interrupts.

    Regards,
    Mark
  • ntsjunntsjun Jun SuOrganization: self employedProject: webapp written in java invoke .net programMember
    mes wrote: »
    The problem is caused by this line:

    future.cancel(true);

    When you pass true to the cancel method, you are allowing it to interrupt a thread if necessary. This interrupt causes a socket used internally by the Ice thread pool to be closed and results in the infinite loop that follows.

    Change the argument to false and everything works as expected. As a general rule, Ice for Java does not work well in the presence of thread interrupts.

    Regards,
    Mark
    Thanks very much,mes. everything is ok now.
Sign In or Register to comment.