宁武皇仁光九年锦文轩刻本《异闻录》载: 扶桑画师浅溪,居泰安,喜绘鲤。院前一方荷塘,锦鲤游曳,溪常与嬉戏。 其时正武德之乱,潘镇割据,战事频仍,魑魅魍魉,肆逆于道。兵戈逼泰安,街邻皆逃亡,独溪不舍锦鲤,未去。 是夜,院室倏火。有人入火护溪,言其本鲤中妖,欲取溪命,却生情愫,遂不忍为之。翌日天明,火势渐歇,人已不见。 溪始觉如梦,奔塘边,但见池水干涸,莲叶皆枯,塘中鲤亦不知所踪。 自始至终,未辨眉目,只记襟上层迭莲华,其色魅惑,似血着泪。 后有青岩居士闻之,叹曰:魑祟动情,必作灰飞。犹蛾之投火耳,非愚,乃命数也。 ————《锦鲤抄》

【达梦8小版本更换后适配flowable6.8报错Error initialising eventregistry data model】

达梦8小版本更换后适配flowable6.8报错

问题背景:

当前代码使用达梦8并适配了flowable6.8工作流,在达梦8小版本2021版更新到达梦8小版本2023后出现报错,报错如下:

 - Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'wfDeployController' defined in file [F:\Zoe\flowable\ruoyi-flowable-plus\ruoyi-admin\target\classes\com\ruoyi\web\controller\workflow\WfDeployController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'wfDeployServiceImpl' defined in file [F:\Zoe\flowable\ruoyi-flowable-plus\ruoyi-system\target\classes\com\ruoyi\workflow\service\impl\WfDeployServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'repositoryServiceBean' defined in class path resource [org/flowable/spring/boot/ProcessEngineServicesAutoConfiguration.class]: Unsatisfied dependency expressed through method 'repositoryServiceBean' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'processEngine': FactoryBean threw exception on object creation; nested exception is org.flowable.common.engine.api.FlowableException: Error initialising eventregistry data model

再往下看报错,还有更具体的报错:

Caused by: java.lang.NumberFormatException: For input string: ""

.............

at liquibase.database.core.DmDatabase.getDatabaseMinorVersion(DmDatabase.java:172)

前后版本记录如下:
新数据库版本:20230927 开发版

select *,id_code from v$version;
--03134284094-20230927-203585-20067 Pack1

旧数据库版本:20211021 开发版

select *,id_code from v$version;
-- 1-2-84-21.10.21-149328-10032-ENT 

问题排查:

​ 首先我没有删除旧版本的数据库,所以我现在运行了两个数据库实例,当我把配置文件对应数据库配置换成原来的配置,则报错消失。

​ 然后我发现DmDatabase.java这个类是我之前做flowable与达梦数据库适配时新建的类(包路径为package liquibase.database.core,是liquibase包下核心类的重写),里面有次版本号获取方法:

    @Override
    public int getDatabaseMinorVersion() throws DatabaseException {
        if (databaseMinorVersion == null) {
            return super.getDatabaseMinorVersion();
        } else {
            return databaseMinorVersion;
        }
    }

这个databaseMinorVersion是null,我沿着父类AbstractJdbcDatabase的getDatabaseMinorVersion()方法追踪,可以找到 DmdbDatabaseMetaData.java类,

public class DmdbDatabaseMetaData extends Filterable implements DatabaseMetaData  {}

最后定位到方法do_getDatabaseMinorVersion:

方法路径:dm.jdbc.driver.DmdbDatabaseMetaData#do_getDatabaseMinorVersion

方法内容:

    public int do_getDatabaseMinorVersion() {
        if (this.connection.compatibleOracle()) {
            return 1;
        } else {
            String[] var1 = this.do_getDatabaseProductVersion().split("\\.");
            return Integer.parseInt(var1[1]);
        }
    }

开启debug,可以看到如果if走的true判断,则返回1,如果走else部分,var1的值为["8", "", "", "03134284094"],这就导致var1[1]时因为获取下标内容是空串,所以转为int时自然报错NumberFormatException

问题解决:

目前来说可能是当前数据库版本解析异常或者没有按照oracle走适配:connection.compatibleOracle

第一种:

添加数据库配置参数:&compatibleMode=oracle

url: jdbc:dm://localhost:5237/PSPG_DEV?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8&compatibleMode=oracle

第二种:

重写liquibase时手动把数据库版本赋值,比如

@Override
public int getDatabaseMinorVersion() throws DatabaseException {
    if (databaseMinorVersion == null) {
        // 如果当达梦数据库的小版本更换后如果报错定位到这里,可以考虑次版本号赋值为1(直接return 1)
        // return super.getDatabaseMinorVersion();
        // return 1;
    } else {
        return databaseMinorVersion;
    }
}
posted @ 2023-11-16 18:48  哒布溜  阅读(624)  评论(0编辑  收藏  举报