jboss 连接到数据库时打开服务器的套接字时出错

deyfvvtc  于 2022-11-08  发布在  其他
关注(0)|答案(3)|浏览(197)

当我的应用程序服务器正在运行时,Jboss无法连接到数据库。我正在运行Docker DB2映像,而不是使用本地数据库。我正在Virtual Box上运行Docker。应用程序正在打开VirtualBox IP的套接字,而不是localhost。错误显示:
错误代码为:Cannot create PoolableConnectionFactory : Exception java.net.ConnectException: Error opening socket to server /192.168.56.1 on port 50,000 with message: Connection refused: connect. ERRORCODE=-4499, SQLSTATE=08001....其中192.168.56.1是我的Virtual Box Ip。我可以通过在本地运行的DB2客户机连接我的DB2 Docker映像,但不能与我的应用程序连接。
记录档:

2019-02-11 18:20:16,806  INFO [ost-startStop-1 ation.ConfigurationClassParser] - Properties location [/opt/demandtec/common/conf/jms.properties] not resolvable: class path resource [opt/demandtec/common/conf/jms.properties] cannot be opened because it does not exist
2019-02-11 18:20:17,877  INFO [ost-startStop-1 redAnnotationBeanPostProcessor] - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2019-02-11 18:20:18,683  INFO [ost-startStop-1 dtec.message.DestReserverBeans] - Loading defalt queue topic definitions
2019-02-11 18:20:18,736  INFO [ost-startStop-1 mandtec.global.DTServiceConfig] - init jndi template
2019-02-11 18:20:18,764  INFO [ost-startStop-1 dtec.global.DTRemotingServices] - Start Locate Registry with port: 3099
2019-02-11 18:20:22,685  INFO [ost-startStop-1 ssage.activemq.DTAMQJmsService] - amq connect meta data created
2019-02-11 18:20:22,691  INFO [ost-startStop-1 .message.InitConnectionFactory] - export: QueueConnectionFactory as interface com.ibm.demandtec.mq.RemoteConnectFactory
2019-02-11 18:20:22,697  INFO [ost-startStop-1 .message.InitConnectionFactory] - export: TopicConnectionFactory as interface com.ibm.demandtec.mq.RemoteConnectFactory
2019-02-11 18:20:22,698  INFO [ost-startStop-1 .message.InitConnectionFactory] - export: PromoCPQueueConnectionFactory as interface com.ibm.demandtec.mq.RemoteConnectFactory
2019-02-11 18:20:22,698  INFO [ost-startStop-1 .message.InitConnectionFactory] - export: PerishableQueueConnectionFactory as interface com.ibm.demandtec.mq.RemoteConnectFactory
2019-02-11 18:20:22,698  INFO [ost-startStop-1 .message.InitConnectionFactory] - export: AMEQueueConnectionFactory as interface com.ibm.demandtec.mq.RemoteConnectFactory
2019-02-11 18:20:22,698  INFO [ost-startStop-1 .message.InitConnectionFactory] - export: FarmQueueConnectionFactory as interface com.ibm.demandtec.mq.RemoteConnectFactory
2019-02-11 18:20:22,720  INFO [ost-startStop-1 .message.InitConnectionFactory] - export: IAMTopicConnectionFactory as interface com.ibm.demandtec.mq.RemoteConnectFactory
2019-02-11 18:20:22,720  INFO [ost-startStop-1 .message.InitConnectionFactory] - export: CTSQueueConnectionFactory as interface com.ibm.demandtec.mq.RemoteConnectFactory
2019-02-11 18:20:22,721  INFO [ost-startStop-1 .message.InitConnectionFactory] - export: GlobalQueueConnectionFactory as interface com.ibm.demandtec.mq.RemoteConnectFactory
2019-02-11 18:20:22,722  INFO [ost-startStop-1 .message.InitConnectionFactory] - export: GlobalTopicConnectionFactory as interface com.ibm.demandtec.mq.RemoteConnectFactory
2019-02-11 18:20:22,731  INFO [ost-startStop-1 ndtec.mq.DTMQConnectionFactory] - Init class: org.apache.activemq.ActiveMQConnectionFactory, with: {brokerURL=tcp://IBM217-PC0BY3X9:61616, trustAllPackages=true}
2019-02-11 18:20:22,992  INFO [ost-startStop-1 ndtec.mq.DTMQConnectionFactory] - Init class: org.apache.activemq.ActiveMQConnectionFactory, with: {brokerURL=tcp://IBM217-PC0BY3X9:61616, clientID=IBM217-PC0BY3X9.IAM, trustAllPackages=true}
2019-02-11 18:20:23,357  WARN [ost-startStop-1 .commons.dbcp2.BasicDataSource] - The requested JMX name [demandtec.com_optimization] was not valid and will be ignored.
2019-02-11 18:20:53,117  INFO [pool-2-thread-1 .demandtec.global.DTMDBService] - Startup AdminMDB
2019-02-11 18:20:54,241  INFO [pool-2-thread-1 .demandtec.global.DTMDBService] - Startup IAM as clientid:IBM217-PC0BY3X9_appiam
2019-02-11 18:30:31,001  WARN [ost-startStop-1 emandtec.dal.ConnectionHandler] - JBossPoolException! Failed getting connection to Optimization for demandtec.com
2019-02-11 18:30:31,001  WARN [ost-startStop-1 emandtec.dal.ConnectionHandler] - cause: Cannot create PoolableConnectionFactory ([jcc][t4][2043][11550][4.22.29] Exception java.net.ConnectException: Error opening socket to server /192.168.56.1 on port 50,000 with message: Connection refused: connect. ERRORCODE=-4499, SQLSTATE=08001)
2019-02-11 18:30:31,001  WARN [ost-startStop-1 emandtec.dal.ConnectionHandler] - will attempt one more time.
2019-02-11 18:30:31,001  WARN [ost-startStop-1 .commons.dbcp2.BasicDataSource] - The requested JMX name [demandtec.com_optimization] was not valid and will be ignored.

数据库:DB2;操作系统:Windows 7/ Docker,基于Linux操作系统;架构:J2EE;应用程序服务器:J老板

balp4ylt

balp4ylt1#

我想我在使用ibmcom/db2社区版映像时也遇到了同样的问题。当我在MacOS上启动容器时,它工作得很好。然后如果我在virtualbox环境中启动容器,jdbc连接就会失败。

[jcc][10521][13706]Command : java com.ibm.db2.jcc.DB2Jcc -user db2inst1 -password********-url jdbc:db2://0.0.0.0:50000/testdb

[jcc][10512][13714]Failed to create connection.
  SQLCODE: -4499
  SQLSTATE: 08001
  Message: [jcc][t4][2030][11211][4.12.55] A communication error occurred during operations on the connection's underlying socket, socket input stream,
or socket output stream.  Error location: Reply.fill() - insufficient data (-1).  Message: Insufficient data. ERRORCODE=-4499, SQLSTATE=08001

有人怀疑是因为ipv6,所以我运行docker run -itd --name mydb2 --privileged=true -p 50000:50000 -e LICENSE=accept -e DB2INST1_PASSWORD=test123 -e DBNAME=testdb -v /home/vagrant/database:/database ibmcom/db2来启动一个容器,然后用docker exec -it mydb2 bash进入容器,删除几行ipv6代码,只保留/etc/hosts文件中的以下代码。

127.0.0.1       localhost
172.17.0.2      def55f9a8b0f

退出并删除此容器。使用命令docker run -itd --name mydb2 --privileged=true -p 0.0.0.0:50000:50000 -e LICENSE=accept -e DB2INST1_PASSWORD=test123 -e DBNAME=testdb -v /home/vagrant/database:/database ibmcom/db2重新启动容器。

CONTAINER ID   IMAGE        COMMAND                  CREATED         STATUS         PORTS                                                          NAMES
4fbaec4a46ac   ibmcom/db2   "/var/db2_setup/lib/…"   7 minutes ago   Up 7 minutes   22/tcp, 55000/tcp, 60006-60007/tcp, 0.0.0.0:50000->50000/tcp   mydb2

稍等片刻,JDBC连接工作正常。

[jcc][10516][13709]Test Connection Successful.

DB product version = SQL11056
DB product name = DB2/LINUXX8664
DB URL = jdbc:db2://127.0.0.1:50000/testdb
DB Drivername = IBM Data Server Driver for JDBC and SQLJ
DB OS Name = Linux
ru9i0ody

ru9i0ody2#

对于任何在podman上遇到此问题的人,只需将rootfull设置为true并重复设置过程

podman machine set --rootful=true
ui7jx7zq

ui7jx7zq3#

在我们的场景中,我们只需添加选项即可解决问题

privileged: true

在docker-compose.yml文件中添加到db2服务

相关问题