gpt4 book ai didi

docker - 无法使用Docker容器连接到Oracle数据库

转载 作者:行者123 更新时间:2023-12-02 20:18:49 26 4
gpt4 key购买 nike

我将应用程序作为EAR文件部署到Webspehre自由服务器上的Docker容器中。

但是,当应用程序运行时,它无法连接到在另一台主机上运行的Oracle数据库,在该主机上,我们试图通过Websphere自由的server.xml中定义的jndi查找进行连接。

<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)

最佳答案

您可以尝试使用IP地址代替xyz.mycomany.com:1521吗?绝对是网络问题,您可能需要浏览https://docs.docker.com/engine/userguide/networking/default_network/
您也可以从容器cat / etc / hosts内部尝试
它应该列出您要连接的IP /机器。

关于docker - 无法使用Docker容器连接到Oracle数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40597193/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com