I have a java spring boot inside docker a container which has to connect to an external Oracle database, i have set the db properties in the application.yml file. The connection shouldn't require TLS/SSL. The tnsnames.ora file is including the connection to the database. The connection works on DBeaver. I am not using docker-compose.
Telnet
on ip 1521 works from the machine, i don't have it the docker container.
sqlplus:
ERROR:
ORA-12170: TNS:Connect timeout occurred
Enter user-name: username
Enter password:
ERROR:
ORA-12162: TNS:net service name is incorrectly specified
tnsping dbname
TNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 03-APR-2025 14:58:53
Copyright (c) 1997, 2019, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = **.**.***.***)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = dbname)))
OK (20 msec)
application.yml
spring:
datasource:
hikari:
connection-timeout: 30000 # 30 seconds (default is 30 seconds)
maximum-pool-size: 30
minimum-idle: 10
db-datasource:
jdbc-url: jdbc:oracle:thin:@**.**.***.***:1521/dbname
username: username
password: password
type: oracle.ucp.jdbc.PoolDataSource
oracleucp:
min-pool-size: 10
max-pool-size: 30
Exception:
2025-04-03 12:30:07 - Servlet.service() for servlet
[dispatcherServlet] in context with path [] threw exception [Request
processing failed; nested exception is
.springframework.jdbc.CannotGetJdbcConnectionException: Failed to
obtain JDBC Connection; nested exception is
java.sql.SQLRecoverableException: ORA-17820: The network adapter could
not establish the connection.
(CONNECTION_ID=Hs5/EibCSvqAgNOlroqmEQ==)] with root cause
oracle.ns.NetException: ORA-17820: The network adapter could not
establish the connection. (CONNECTION_ID=Hs5/EibCSvqAgNOlroqmEQ==)
at oracle.nt.ConnStrategy.execute(ConnStrategy.java:729)
at oracle.resolver.AddrResolution.resolveAndExecute(AddrResolution.java:688)
at oracle.ns.NSProtocol.establishConnection(NSProtocol.java:935)
at oracle.ns.NSProtocol.establishConnection(NSProtocol.java:908)
at oracle.ns.NSProtocolNIO.redirectConnection(NSProtocolNIO.java:519)
at oracle.ns.NSProtocolNIO.handleConnectPacketResponse(NSProtocolNIO.java:441)
at oracle.ns.NSProtocolNIO.negotiateConnection(NSProtocolNIO.java:262)
at oracle.ns.NSProtocol.connect(NSProtocol.java:327)
at oracle.jdbc.driver.T4CConnection.connectSession(T4CConnection.java:2882)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:811)
at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:1132)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:104)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:837)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:664)
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:364)
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206)
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:476)
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561)
at com.zaxxer.hikari.pool.HikariPool.<init(HikariPool.java:115)
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
at .springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:159)
at .springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:117)
at .springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80)
at .springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:646)
at .springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:713)
at .springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:738)
at .springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:794)
at .springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.query(NamedParameterJdbcTemplate.java:209)
at .springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.query(NamedParameterJdbcTemplate.java:221)
at it.telecomitalia.mdc.gino.repository.GinoRepository.getOfferTypeByCode(GinoRepository.java:70)
at it.telecomitalia.mdc.gino.repository.GinoRepository$$FastClassBySpringCGLIB$$636333f4.invoke(<generated)
at .springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
at .springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793)
at .springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at .springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
at .springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137)
at .springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at .springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
at .springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708)
at it.telecomitalia.mdc.gino.repository.GinoRepository$$EnhancerBySpringCGLIB$$58afd782.getOfferTypeByCode(<generated)
at it.telecomitalia.mdc.gino.service.GinoService.getOfferType(GinoService.java:16)
at it.telecomitalia.mdc.fetrcs.service.FetrcsServiceInformative.getOffers(FetrcsServiceInformative.java:261)
at it.telecomitalia.mdc.fetrcs.controller.FetrcsController.getOffers(FetrcsController.java:61)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at .springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
at .springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)
at .springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)
at .springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
at .springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
at .springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at .springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1071)
at .springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:964)
at .springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
at .springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:670)
at .springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:779)
at .apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
at .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at .apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at .apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at .springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
at .springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at .apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at .springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
at .springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at .apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at .springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:96)
at .springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at .apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at .springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
at .springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at .apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at .apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:177)
at .apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
at .apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
at .apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
at .apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at .apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
at .apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
at .apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
at .apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at .apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:891)
at .apache.tomcat.util.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1784)
at .apache.tomcat.util.SocketProcessorBase.run(SocketProcessorBase.java:49)
at .apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
at .apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
at .apache.tomcat.util.threads.TaskThread$WrappingRu