title: Spring boot Show Error with tomcat 8 connection pool Too many open files
body: <p>Anybody may be help?</p>
  
  <p>I have app that I bilt In Spring Boot whith externa Tomcat 8 using connection pool in context.xml.</p>
  
  <p>But when I call with threads show me error after few minutes.</p>
  
  <p>Look my code and configuration:</p>
  
  <p>TKS 4ALL!!!</p>
  
  <p><strong>context.xml</strong></p>
  
  <pre><code> &lt;Resource name="jdbc/ocp-api" auth="Container"
   type="javax.sql.DataSource"
                    maxTotal="150"
                      max-active= "100" 
                     max-idle= "80"
                      min-idle="8"
                      maxWaitMillis="2000"
                      username="postgres" 
                      password="postgres" 
                      driverClassName="org.postgresql.Driver"
                      url="jdbc:postgresql://&lt;myIpServer&gt;:5432/db_ocp_ago2017"/&gt;
  </code></pre>
  
  <p><strong>application.properties</strong></p>
  
  <pre><code>spring.datasource.jndi-name=jdbc/ocp-api
  
  
  
  spring.jpa.show-sql=true
  
  spring.application.name=ocp-api
  server.contextPath=/ocp-api
  spring.jackson.date-format=yyyy-MM-dd HH:mm:ss.SSSZ
  spring.jackson.joda-date-time-format=yyyy-MM-dd' 'HH:mm:ss.SSSZ
  
  logging.level.org.springframework.web=ERROR
  logging.level.com.mkyong=DEBUG
  
  
  # Logging pattern for the console
  logging.pattern.console= "%d{yyyy-MM-dd HH:mm:ss} - %msg%n"
  
  # Logging pattern for file
  logging.pattern.file= "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"
  
  logging.file=/var/supportcomm/ocp/log/ocp-api.log
  flyway.baselineOnMigrate=true
  </code></pre>
  
  <blockquote>
    <p>26-Jul-2018 16:40:29.049 WARNING
    [ContainerBackgroundProcessor[StandardEngine[Catalina]]]
    org.apache.catalina.deploy.NamingResourcesImpl.cleanUp Failed to
    retrieve JNDI naming context for container
    [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/ocp-api]]
    so no cleanup was performed for that container</p>
    
    <p>javax.naming.NameNotFoundException: Name [comp/env] is not bound in
    this Context. Unable to find [comp].
            at org.apache.naming.NamingContext.lookup(NamingContext.java:824)
            at org.apache.naming.NamingContext.lookup(NamingContext.java:172)
            at org.apache.catalina.deploy.NamingResourcesImpl.cleanUp(NamingResourcesImpl.java:993)
            at org.apache.catalina.deploy.NamingResourcesImpl.stopInternal(NamingResourcesImpl.java:975)
            at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:221)
            at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5551)
            at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:221)
            at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:259)
            at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:832)
            at org.apache.catalina.startup.HostConfig.undeploy(HostConfig.java:1395)
            at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1303)
            at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1581)
            at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:284)
            at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:95)
            at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
            at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1140)
            at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1376)
            at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1380)
            at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1348)
            at java.lang.Thread.run(Thread.java:745)  </p>
    
    <p>"2018-07-26 16:51:27 - Cannot forward to error page for request
    [/occupation] as the response has already been committed. As a result,
    the response may have the wrong status code. If your application is
    running on WebSphere Application Server you may be able to resolve
    this problem by setting
    com.ibm.ws.webcontainer.invokeFlushAfterService to false
    "org.apache.catalina.connector.ClientAbortException:
    java.io.IOException: Broken pipe
            at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:396)
            at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:426)
            at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:345)
            at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:320)
            at org.apache.catalina.connector.CoyoteOutputStream.flush(CoyoteOutputStream.java:110)
            at com.fasterxml.jackson.core.json.UTF8JsonGenerator.flush(UTF8JsonGenerator.java:1054)
            at com.fasterxml.jackson.databind.ObjectWriter.writeValue(ObjectWriter.java:607)
            at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.writeInternal(AbstractJackson2HttpMessageConverter.java:286)
            at org.springframework.http.converter.AbstractGenericHttpMessageConverter.write(AbstractGenericHttpMessageConverter.java:106)
            at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:231)
            at org.springframework.web.servlet.mvc.method.annotation.HttpEntityMethodProcessor.handleReturnValue(HttpEntityMethodProcessor.java:203)
            at org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue(HandlerMethodReturnValueHandlerComposite.java:81)
            at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:113)
            at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
            at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
            at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
            at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)
            at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
            at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
            at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
            at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)</p>
    
    <p>Caused by: java.io.IOException: Broken pipe
            at sun.nio.ch.FileDispatcherImpl.write0(Native Method)
            at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47)
            at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93)
            at sun.nio.ch.IOUtil.write(IOUtil.java:65)
            at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471)
            at org.apache.tomcat.util.net.NioChannel.write(NioChannel.java:124)
            at org.apache.tomcat.util.net.NioBlockingSelector.write(NioBlockingSelector.java:101)
            at org.apache.tomcat.util.net.NioSelectorPool.write(NioSelectorPool.java:172)
            at org.apache.coyote.http11.InternalNioOutputBuffer.writeToSocket(InternalNioOutputBuffer.java:139)
            at org.apache.coyote.http11.InternalNioOutputBuffer.addToBB(InternalNioOutputBuffer.java:197)
            at org.apache.coyote.http11.InternalNioOutputBuffer.access$000(InternalNioOutputBuffer.java:41)
            at org.apache.coyote.http11.InternalNioOutputBuffer$SocketOutputBuffer.doWrite(InternalNioOutputBuffer.java:320)
            at org.apache.coyote.http11.filters.ChunkedOutputFilter.doWrite(ChunkedOutputFilter.java:118)
            at org.apache.coyote.http11.AbstractOutputBuffer.doWrite(AbstractOutputBuffer.java:256)
            at org.apache.coyote.Response.doWrite(Response.java:491)
            at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:391)
            ... 66 common frames omitted</p>
    
    <p>26-Jul-2018 16:52:20.989 SEVERE [http-nio-8280-Acceptor-0]
    org.apache.tomcat.util.net.NioEndpoint$Acceptor.run Socket accept
    failed java.io.IOException: Too many open files
            at sun.nio.ch.ServerSocketChannelImpl.accept0(Native Method)
            at sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:422)
            at sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:250)
            at org.apache.tomcat.util.net.NioEndpoint$Acceptor.run(NioEndpoint.java:693)
            at java.lang.Thread.run(Thread.java:745)  </p>
    
    <p>[pool-24-thread-14] WARN
    org.hibernate.engine.jdbc.spi.SqlExceptionHelper - SQL Error: 0,
    SQLState: 08001"2018-07-26 16:52:32 - SQL Error: 0, SQLState: null
    2018-07-26 16:52:32 - SQL Error: 0, SQLState: null 2018-07-26 16:52:32
    - SQL Error: 0, SQLState: null 2018-07-26 16:52:32 - SQL Error: 0, SQLState: null 2018-07-26 16:52:32 - SQL Error: 0, SQLState: null
    2018-07-26 16:52:32 - SQL Error: 0, SQLState: null 2018-07-26 16:52:33
    - java.io.FileNotFoundException: /vol/app/apache-tomcat-8.0.38/webapps/ocp-api/WEB-INF/lib/jackson-core-2.8.10.jar
    (Too many open files) 2018-07-26 16:52:34 -
    java.io.FileNotFoundException:
    /vol/app/apache-tomcat-8.0.38/webapps/ocp-api/WEB-INF/lib/jackson-core-2.8.10.jar
    (Too many open files) 2018-07-26 16:52:34 -
    java.io.FileNotFoundException:
    /vol/app/apache-tomcat-8.0.38/webapps/ocp-api/WEB-INF/lib/jackson-core-2.8.10.jar
    (Too many open files)</p>
  </blockquote>