This forum has been archived. Please start a new discussion on GitHub.

Too many open files with IceJ


I have a simple Ice Client/Server application in a Linux environment (Fedora Core 4 in the client side and Mandriva LE 2005 in the server side). The server is a simple Ice.Application, and the client is a Java servlet.

This is the


I run 20 concurrent requests, and all works fine. I run 20 more concurrent, and the client hasn't problems. But if I run 20 more concurrent requests, the client (jakarta tomcat) throws a lot of exceptions:

error: cannot create thread pool for connection:
error = 0
at IceInternal.Network.createTcpSocket(
Caused by: Too many open files
at Method)

What's the matter?

I attach the server and client main classes in this issue.

Thanks a lot for helping me!

P.D.: I'm testing ICE for future developments. We have already programmed a medium multithread search java program, and we want to know if ICE is faster than a classical multithreading implementation.


  • dwayne
    dwayne St. John's, Newfoundland
    Please see for our support policy.
  • Hi dwayne,

    I apologize for the mistake... ;) (i'm newbie)

    Best regards...
  • mes
    mes California

    Creating a communicator is an expensive operation, and is not something I would recommend doing for every HTTP request.

    Rather, your servlet should create the communicator once (e.g., in the servlet's init method) and use that same instance for every HTTP request. Furthermore, if all HTTP requests result in invocations on the same Ice object, then your servlet should also create the proxy in the init method.

    For example:
    public class MyServlet extends HttpServlet
        public void init() throws ServletException
                String[] args = {};
                _communicator = Ice.Util.initialize(args);
                Ice.ObjectPrx proxy = _communicator.stringToProxy("...");
                _searcher = SearcherPrxHelper.checkedCast(proxy);
                if(_searcher == null)
                    throw new UnavailableException("Invalid proxy");
            catch(Exception ex)
                UnavailableException e = new UnavailableException("Ice failure");
                throw e;
        public void destroy()
            if(_communicator != null)
                catch(Exception ex)
                    // Ignore
        private Ice.Communicator _communicator;
        private SearcherPrx _searcher;
    We'll investigate whether the exception you saw is the result of a problem in Ice.

    Take care,
    - Mark
  • Fantastic!

    Hi Mark!

    It works!!! Thanks a lot for your time!!! :D

    Best regards!