第6篇:Flowable-Modeler详述之常见问题Table act_ge_property doesn't exist
接上一篇:
第5篇: Flowable-Modeler詳述之開發(fā)環(huán)境搭建
https://blog.csdn.net/weixin_40816738/article/details/102887854
文章目錄
- 1. 問題描述
- 2. 問題定位
- 解決方案一
- 解決方案二(推薦)
1. 問題描述
在配置完Springboot的開發(fā)環(huán)境以后,啟動的時候遇到了這個問題,數據庫版本為mysql 5.7,Flowable版本為6.4.0,詳細報錯如下:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'flowController': Unsatisfied dependency expressed through field 'flowService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'flowServiceImpl': Unsatisfied dependency expressed through field 'repositoryService'; 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.UnsatisfiedDependencyException: Error creating bean with name 'processEngine' defined in class path resource [org/flowable/spring/boot/ProcessEngineServicesAutoConfiguration$AlreadyInitializedAppEngineConfiguration.class]: Unsatisfied dependency expressed through method 'processEngine' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flowableAppEngine': FactoryBean threw exception on object creation; nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: java.sql.SQLSyntaxErrorException: Table 'flowstudy.act_ge_property' doesn't exist ### The error may exist in org/flowable/db/mapping/entity/Property.xml ### The error may involve org.flowable.engine.impl.persistence.entity.PropertyEntityImpl.selectProperty-Inline ### The error occurred while setting parameters ### SQL: select * from ACT_GE_PROPERTY where NAME_ = ? ### Cause: java.sql.SQLSyntaxErrorException: Table 'flowstudy.act_ge_property' doesn't existat org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:586) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:372) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1341) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:572) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:759) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869) ~[spring-context-5.0.9.RELEASE.jar:5.0.9.RELEASE]at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.0.9.RELEASE.jar:5.0.9.RELEASE]at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:780) [spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412) [spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]at org.springframework.boot.SpringApplication.run(SpringApplication.java:333) [spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]at org.springframework.boot.SpringApplication.run(SpringApplication.java:1277) [spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]at org.springframework.boot.SpringApplication.run(SpringApplication.java:1265) [spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]at com.hyj.main.App.main(App.java:22) [classes/:na]at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_191]at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_191]at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_191]at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_191]at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.0.5.RELEASE.jar:2.0.5.RELEASE]2. 問題定位
看提示顯示表不存在說明數據庫中沒有該表,此時查看的確沒有,但是Flowable啟動的時候應該會自動創(chuàng)建表的,說明表創(chuàng)建的邏輯判斷發(fā)生問題
查看代碼發(fā)現判斷主要函數為:
代碼位于類 ProcessDbSchemaManager中,核心判斷存在如下:
public void schemaCreate() {this.getCommonSchemaManager().schemaCreate();this.getIdentityLinkSchemaManager().schemaCreate();this.getTaskSchemaManager().schemaCreate();this.getVariableSchemaManager().schemaCreate();this.getJobSchemaManager().schemaCreate();//使用這個函數判斷是否要創(chuàng)建引擎if (this.isEngineTablePresent()) {String dbVersion = this.getDbVersion();if (!"6.4.0.0".equals(dbVersion)) {throw new FlowableWrongDbException("6.4.0.0", dbVersion);}} else {this.dbSchemaCreateEngine();}if (CommandContextUtil.getDbSqlSession().getDbSqlSessionFactory().isDbHistoryUsed()) {this.dbSchemaCreateHistory();} }更新的時候,設置databaseSchemaUpdate=true的時候,走update,可以看到如下代碼也是使用isEngineTablePresent來判斷是否存在
public String schemaUpdate() {PropertyEntity dbVersionProperty = null;String dbVersion = null;String feedback = null;boolean isUpgradeNeeded = false;int matchingVersionIndex = -1;int version6120Index = FlowableVersions.getFlowableVersionIndexForDbVersion("6.1.2.0");DbSqlSession dbSqlSession = CommandContextUtil.getDbSqlSession();boolean isEngineTablePresent = this.isEngineTablePresent();if (isEngineTablePresent) {dbVersionProperty = (PropertyEntity)dbSqlSession.selectById(PropertyEntityImpl.class, "schema.version");dbVersion = dbVersionProperty.getValue();matchingVersionIndex = FlowableVersions.getFlowableVersionIndexForDbVersion(dbVersion);isUpgradeNeeded = matchingVersionIndex != FlowableVersions.FLOWABLE_VERSIONS.size() - 1;}boolean isHistoryTablePresent = this.isHistoryTablePresent();if (isUpgradeNeeded && matchingVersionIndex < version6120Index) {this.dbSchemaUpgradeUntil6120("engine", matchingVersionIndex);if (isHistoryTablePresent) {this.dbSchemaUpgradeUntil6120("history", matchingVersionIndex);}}this.getCommonSchemaManager().schemaUpdate();this.getIdentityLinkSchemaManager().schemaUpdate();this.getTaskSchemaManager().schemaUpdate();this.getVariableSchemaManager().schemaUpdate();this.getJobSchemaManager().schemaUpdate();if (isUpgradeNeeded) {dbVersionProperty.setValue("6.4.0.0");PropertyEntity dbHistoryProperty;if ("5.0".equals(dbVersion)) {dbHistoryProperty = (PropertyEntity)CommandContextUtil.getPropertyEntityManager().create();dbHistoryProperty.setName("schema.history");dbHistoryProperty.setValue("create(5.0)");dbSqlSession.insert(dbHistoryProperty);} else {dbHistoryProperty = (PropertyEntity)dbSqlSession.selectById(PropertyEntity.class, "schema.history");}String dbHistoryValue = "upgrade(" + dbVersion + "->" + "6.4.0.0" + ")";dbHistoryProperty.setValue(dbHistoryValue);if (version6120Index > matchingVersionIndex) {this.dbSchemaUpgrade("engine", version6120Index);} else {this.dbSchemaUpgrade("engine", matchingVersionIndex);}feedback = "upgraded Flowable from " + dbVersion + " to " + "6.4.0.0";} else if (!isEngineTablePresent) {this.dbSchemaCreateEngine();}if (isHistoryTablePresent) {if (isUpgradeNeeded) {if (version6120Index > matchingVersionIndex) {this.dbSchemaUpgrade("history", version6120Index);} else {this.dbSchemaUpgrade("history", matchingVersionIndex);}}} else if (dbSqlSession.getDbSqlSessionFactory().isDbHistoryUsed()) {this.dbSchemaCreateHistory();}return feedback;}isEngineTablePresent代碼實現如下:
可以看到使用的是表ACT_RU_EXECUTION是否存在來判斷的
進一步跟蹤看到isTablePresent的實現如下:
public boolean isTablePresent(String tableName) {DbSqlSession dbSqlSession = this.getDbSqlSession();DbSqlSessionFactory dbSqlSessionFactory = dbSqlSession.getDbSqlSessionFactory();if (!dbSqlSession.getDbSqlSessionFactory().isTablePrefixIsSchema()) {tableName = this.prependDatabaseTablePrefix(tableName);}Connection connection = null;try {connection = dbSqlSession.getSqlSession().getConnection();DatabaseMetaData databaseMetaData = connection.getMetaData();ResultSet tables = null;String catalog = dbSqlSession.getConnectionMetadataDefaultCatalog();if (dbSqlSessionFactory.getDatabaseCatalog() != null && dbSqlSessionFactory.getDatabaseCatalog().length() > 0) {catalog = dbSqlSessionFactory.getDatabaseCatalog();}String schema = dbSqlSession.getConnectionMetadataDefaultSchema();if (dbSqlSessionFactory.getDatabaseSchema() != null && dbSqlSessionFactory.getDatabaseSchema().length() > 0) {schema = dbSqlSessionFactory.getDatabaseSchema();} else if (dbSqlSessionFactory.isTablePrefixIsSchema() && StringUtils.isNotEmpty(dbSqlSessionFactory.getDatabaseTablePrefix())) {schema = dbSqlSessionFactory.getDatabaseTablePrefix();if (StringUtils.isNotEmpty(schema) && schema.endsWith(".")) {schema = schema.substring(0, schema.length() - 1);}}String databaseType = dbSqlSessionFactory.getDatabaseType();if ("postgres".equals(databaseType)) {tableName = tableName.toLowerCase();}if (schema != null && "oracle".equals(databaseType)) {schema = schema.toUpperCase();}if (catalog != null && catalog.length() == 0) {catalog = null;}boolean var10;try {//查詢元數據中的表,根據schema和tablename查看tables = databaseMetaData.getTables(catalog, schema, tableName, JDBC_METADATA_TABLE_TYPES);var10 = tables.next();} finally {try {if (tables != null) {tables.close();}} catch (Exception var18) {LOGGER.error("Error closing meta data tables", var18);}}return var10;} catch (Exception var20) {throw new FlowableException("couldn't check if tables are already present using metadata: " + var20.getMessage(), var20);}}我們啟動程序跟蹤進入,查看使用getTables讀取表,如下圖所示:
-因為機器上以前其他的mysql數據庫中部署過Flowable的表,所以當schema為空的時候搜索mysql的元數據的時候搜索到了歷史用的表,但是不在該數據庫中,所以程序以為表已經有了,但是其實還是歷史的表,到此我們基本上找到原因了。
我們使用的驅動為8.0的驅動,8.0版本驅動將參數 nullCatalogMeansCurrent 的默認值由true改為了false,如果你使用DatabaseMetaData.getTables獲取所有的表信息。
解決方案一
把正常的數據庫的表導出為sql,手動創(chuàng)建表。
解決方案二(推薦)
mysql的連接字符串中添加上nullCatalogMeansCurrent=true,將schema默認設置為當前連接的schema。
完整的數據庫配置信息
# 數據源配置 spring:datasource:driverClassName: com.mysql.cj.jdbc.Driverurl: jdbc:mysql://127.0.0.1:3306/flowstudy?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&autoReconnect=true&&zeroDateTimeBehavior=convertToNull&useSSL=true&allowMulQueries=true&nullCatalogMeansCurrent=trueusername: rootpassword: root下一篇:
第7篇:Flowable-Modeler集成之Flowable源碼編譯
https://blog.csdn.net/weixin_40816738/article/details/102899693
總結
以上是生活随笔為你收集整理的第6篇:Flowable-Modeler详述之常见问题Table act_ge_property doesn't exist的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Apache JMeter 启动
- 下一篇: 解决:'webpack-dev-serv