Docker Community Forums

Share and learn in the Docker community.

Not able to connect to Oracle Database using Docker Container

docker
dockercloud
dockerhub

(Najmulk) #1

I am deploying my application into a Docker container, on Webspehre liberty server as an EAR file.

However, when the application is running, it cannot connect to the Oracle Database which is running on another host where we are trying to connect through jndi lookup defined in server.xml of Websphere liberty.


<properties.oracle URL=“jdbc:oracle:thin:@//xyz.mycomany.com:1521/prexyz” username=“" password="” />

We are able to ping the server from inside the container and getting response but at run time, it is not able to establish the db connection.

Note:- Oracle DB is not containerized. We are simply trying to establish the connection through jndi lookup as mentioned above.

Below is the error message. Could anyone help on how to connect Database in this scenario?Thanks in advance !!

"
[ERROR ] Context initialization failed
Error creating bean with name ‘myappFacade’: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private transient com.mycompany.myappTool.service.util.HibernateUtil com.mycompany.myappTool.service.facade.myappToolFacade.hibernateUtil; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘hibernateUtil’ defined in file [/opt/ibm/wlp/usr/servers/defaultServer/apps/expanded/myapp.ear/myappTool.war/WEB-INF/classes/com/mycompany/myappTool/service/util/HibernateUtil.class]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: com.mycompany.myappTool.service.util.HibernateUtil (initialization failure)
[ERROR ] SRVE0271E: Uncaught init() exception created by servlet [myapp] in application [myapp]: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘myappFacade’: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private transient com.mycompany.myappTool.service.util.HibernateUtil com.mycompany.myappTool.service.facade.myappToolFacade.hibernateUtil; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘hibernateUtil’ defined in file [/opt/ibm/wlp/usr/servers/defaultServer/apps/expanded/myapp.ear/myappTool.war/WEB-INF/classes/com/mycompany/myappTool/service/util/HibernateUtil.class]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: com.mycompany.myappTool.service.util.HibernateUtil (initialization failure)

"


(Najmulk) #2

Forgot to share the datasource details used in server.xml.

dataSource id=“oracle” jndiName=“jdbc/QADBApp” type=“javax.sql.Datasource”>
jdbcDriver libraryRef=“OracleJDBCLib”/>
properties.oracle URL=“jdbc:oracle:thin:@//xyz.mycomany.com:1521/prexyz” username=“" password="” />
/dataSource>


(David Maze) #3

That doesn’t look like a database connectivity error to me.