Results 1 to 6 of 6

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

  1. #1
    ntsjun is offline Registered User
    Name: Jun Su
    Organization: self employed
    Project: webapp written in java invoke .net program
    Join Date
    Aug 2010
    Posts
    5

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

    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.StealProo f));


        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(Thread PoolWorkQueue.java:
    166)
    at IceInternal.ThreadPoolWorkQueue.message(ThreadPool WorkQueue.java:114)
    at IceInternal.ThreadPool.run(ThreadPool.java:302)
    at IceInternal.ThreadPool.access$300(ThreadPool.java: 12)
    at IceInternal.ThreadPool$EventHandlerThread.run(Thre adPool.java:643)
    at java.lang.Thread.run(Thread.java:619)
    Caused by: java.nio.channels.ClosedChannelException
    at sun.nio.ch.SocketChannelImpl.ensureWriteOpen(Socke tChannelImpl.java:1
    26)
    at sun.nio.ch.SocketChannelImpl.write(SocketChannelIm pl.java:324)
    at sun.nio.ch.SinkChannelImpl.write(SinkChannelImpl.j ava:96)
    at IceInternal.ThreadPoolWorkQueue.postMessage(Thread PoolWorkQueue.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(Thread PoolWorkQueue.java:
    166)
    at IceInternal.ThreadPoolWorkQueue.message(ThreadPool WorkQueue.java:114)
    at IceInternal.ThreadPool.run(ThreadPool.java:302)
    at IceInternal.ThreadPool.access$300(ThreadPool.java: 12)
    at IceInternal.ThreadPool$EventHandlerThread.run(Thre adPool.java:643)
    at java.lang.Thread.run(Thread.java:619)
    Caused by: java.nio.channels.ClosedChannelException
    at sun.nio.ch.SocketChannelImpl.ensureWriteOpen(Socke tChannelImpl.java:1
    26)

    is there some wrong in client JAVA code ?
    Last edited by ntsjun; 08-17-2010 at 09:24 AM.

  2. #2
    mes's Avatar
    mes
    mes is offline ZeroC Staff
    Name: Mark Spruiell
    Organization: ZeroC, Inc.
    Project: Ice Developer
    Join Date
    Feb 2003
    Location
    California
    Posts
    1,445
    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

  3. #3
    ntsjun is offline Registered User
    Name: Jun Su
    Organization: self employed
    Project: webapp written in java invoke .net program
    Join Date
    Aug 2010
    Posts
    5
    Quote Originally Posted by mes View Post
    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!
    Attached Files Attached Files

  4. #4
    ntsjun is offline Registered User
    Name: Jun Su
    Organization: self employed
    Project: webapp written in java invoke .net program
    Join Date
    Aug 2010
    Posts
    5

    any body can help me ?

    any body can help me ?

  5. #5
    mes's Avatar
    mes
    mes is offline ZeroC Staff
    Name: Mark Spruiell
    Organization: ZeroC, Inc.
    Project: Ice Developer
    Join Date
    Feb 2003
    Location
    California
    Posts
    1,445
    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

  6. #6
    ntsjun is offline Registered User
    Name: Jun Su
    Organization: self employed
    Project: webapp written in java invoke .net program
    Join Date
    Aug 2010
    Posts
    5
    Quote Originally Posted by mes View Post
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Ice Thread Pool problem
    By alex_leshii in forum Help Center
    Replies: 7
    Last Post: 04-08-2012, 12:04 AM
  2. AssertionError in client thread pool
    By dhogan in forum Help Center
    Replies: 7
    Last Post: 09-02-2009, 07:32 PM
  3. ICE Server Thread Pool Implementation Issues
    By simondu in forum Help Center
    Replies: 3
    Last Post: 10-25-2007, 10:52 PM
  4. ICE thread pool model under windows
    By simondu in forum Comments
    Replies: 3
    Last Post: 09-21-2007, 06:08 AM
  5. How to obtain Ice thread-pool's internal state?
    By timeguest in forum Help Center
    Replies: 1
    Last Post: 09-07-2005, 11:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •