Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the error report of expanding activiti to delete ACT_HI_* history table

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

Today, the editor will share with you the relevant knowledge points about how to expand activiti to delete ACT_HI_* history table and report errors. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look.

Activiti comes with many tables, as shown in the figure:

ACT_HI_*:HI represents historical data (History) tables, including expired process instances, expired variables, expired tasks, and so on.

No foreign keys are created in the history table, so you can control the history table very well.

In a project, there may be no need to save history, that is, these ACT_HI_* tables can be deleted.

Delete the ACT_HI_* history table, restart the project and report an error:

Serious: Error while closing command contextorg.activiti.engine.ActivitiException: Activiti database problem: Tables missing for component (s) history at org.activiti.engine.impl.db.DbSqlSession.dbSchemaCheckVersion (DbSqlSession.java:713) at org.activiti.engine.impl.db.DbSqlSession.performSchemaOperationsProcessEngineBuild (DbSqlSession.java:1097) at org.activiti.engine.impl.SchemaOperationsProcessEngineBuild.execute (SchemaOperationsProcessEngineBuild.java:27) at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute (CommandExecutorImpl. Java:24) at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute (CommandContextInterceptor.java:60) at org.activiti.engine.impl.interceptor.LogInterceptor.execute (LogInterceptor.java:32) at org.activiti.engine.impl.ProcessEngineImpl. (ProcessEngineImpl.java:75) at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.buildProcessEngine (ProcessEngineConfigurationImpl.java:311) at org.activiti.engine.ProcessEngines.buildProcessEngine (ProcessEngines.java: 194) at org.activiti.engine.ProcessEngines.initProcessEnginFromResource (ProcessEngines.java:167) at org.activiti.engine.ProcessEngines.init (ProcessEngines.java:98)

Navigate to the wrong place: DbSqlSession.java

If (dbSqlSessionFactory.isDbHistoryUsed () & &! isHistoryTablePresent ()) {errorMessage = addMissingComponent (errorMessage, "history");}

The main work here is to check whether there is a history table in the database, because the history table in the database is deleted, so the error is reported.

There is a very important variable dbSqlSessionFactory.isDbHistoryUsed (), which means from the code that you can close the usage history table, well, set it to false when you create the configuration file.

ProcessEngineConfiguration configuration = ProcessEngineConfiguration .createProcessEngineConfigurationFromResourceDefault (); if (configuration instanceof ProcessEngineConfigurationImpl) {/ / the main purpose here is to delete historical data without checking whether the historical database exists at startup ((ProcessEngineConfigurationImpl) configuration) .setDbHistoryUsed (false) } ProcessEngine processEngine = configuration.buildProcessEngine ()

There was still a problem after the reboot, and then debug followed up and found that it was using:

ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine ()

When using the above code to get the engine, I went to load the configuration file again. After a long time, I found out:

When ProcessEngines.getDefaultProcessEngine () gets the default activiti engine, it first determines whether the activiti configuration file has been loaded according to the field isInitialized. If it is not loaded, it loads activiti.cfg.xml and activiti-context.xml. If so, the corresponding engine is obtained in processEngines according to its name.

When you create an activiti engine using configuration.buildProcessEngine (), the activiti configuration file is loaded, and then the created engine is added to the processEngines of the utility class ProcessEngines. The field isInitialized is not set.

So when you use ProcessEngines.getDefaultProcessEngine () to get the default activiti engine in your project, you load the configuration file information for the first time.

How to solve this?

Later, I thought that the configuration information in activiti.cfg.xml needs to be loaded into ProcessEngineConfigurationImpl, so it should be parsed first, and then find the set method of the corresponding property for assignment (I guess). Then set it through the configuration file:

After the launch of the project, the success, no longer reported an error.

These are all the contents of this article entitled "how to solve errors in expanding activiti to delete ACT_HI_* history tables". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report