达梦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。
https://blog.csdn.net/qq_35349982/article/details/129624838
问题解决:
目前来说可能是当前数据库版本解析异常或者没有按照oracle走适配:connection.compatibleOracle
第一种:
添加数据库配置URL的参数:&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;
}
}
思考:
报错信息追踪还是很有必要的(笑
标签:return,flowable,适配,数据库,报错,getDatabaseMinorVersion,Error From: https://www.cnblogs.com/dabuliu/p/17837029.html