我正在将我的应用程序部署到一个Docker容器中,在Webspehre liberty服务器上作为EAR文件。
但是,当应用程序运行时,它无法连接到我们尝试通过Websphere自由的server.xml中定义的jndi查找连接的另一台主机上运行的Oracle数据库。
<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="****" />
我们能够从容器内部ping服务器并获得响应,但在运行时,它无法建立数据库连接。
注意: - Oracle DB不是容器化的。我们只是试图通过jndi查找建立连接,如上所述。
以下是错误消息。在这种情况下,有没有人可以帮助如何连接数据库?提前感谢!!
[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)
答案 0 :(得分:0)
你可以尝试使用ip地址而不是xyz.mycomany.com:1521吗?这肯定是一个网络问题,你可能想要通过https://docs.docker.com/engine/userguide/networking/default_network/ 您也可以在容器cat / etc / hosts中尝试 它应该列出你要连接的ip /机器。