Tigase8.x 搭配Mysql8及以上启动时报错(Nodes redirection table: tig_cluster_nodes doesn't exits)的解决方法

Tigase 启动时报如下错误:

=====================
Could not initialize bean default (class: class tigase.server.xmppclient.SeeOtherHostDualIP$DualIPRepositoryWrapper$DualIPRepositoryWrapperConfigBean), skipping injection of this bean
RootCause:
   -> java.lang.RuntimeException: Repository initialization failed
      [tigase.server.xmppclient.SeeOtherHostDualIPSQLRepository.setDataSource(SeeOtherHostDualIPSQLRepository.java:61)]
      -> java.sql.SQLException: Nodes redirection table: tig_cluster_nodes doesn't exits!
         [tigase.server.xmppclient.SeeOtherHostDualIPSQLRepository.checkDB(SeeOtherHostDualIPSQLRepository.java:103)]
=====================

 

项目中数据库链接的配置:

 uri = 'jdbc:mysql://localhost/tig8_db?user=root&password=123456&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai'

 

1、分析问题: 通过定位发现此为Tigase的兼容BUG,导致问题源代码处:

tigase.db.jdbc.DataRepositoryImpl

if (db_conn != null) {
			switch (database) {
				case jtds:
				case sqlserver:
					table_schema = "dbo";
					break;
				case postgresql:
					table_schema = "public";
					break;
				default:
					String[] slashes = db_conn.split("/");
					table_schema = slashes[slashes.length - 1].split("\\?")[0];
					break;
			}
			log.log(Level.INFO, "Table schema found: {0}, database type: {1}, database driver: {2}",
					new Object[]{table_schema, database.toString(), driverClass});
		}

 

2、定位到问题点: 如果使用的是Mysql8及以上,URL需要配置时区 :serverTimezone=Asia/Shanghai',则以下代码切割出来的table_schema 为Shanghai,导致取不正确的值tig8_db,从而报错!  

String[] slashes = db_conn.split("/");
table_schema = slashes[slashes.length - 1].split("\\?")[0]; // error ==> Shanghai

  

3、解决问题: 在官方还没修复之前,通过以下方式可以修复:

String[] slashes = db_conn.split("/");
for (String slash : slashes) {
    if (slash != null && slash.contains("?")) {
        table_schema = slash.split("\\?")[0];
        break;
    }
}

  

 

上一篇:flutter Target of URI doesn't exist


下一篇:2021-01-30