cancel
Showing results for 
Search instead for 
Did you mean: 

Ibatis exception

luisalves00
Champ in-the-making
Champ in-the-making
I'm getting this exception:

Caused by: org.apache.ibatis.transaction.TransactionException: Error configuring AutoCommit.  Your driver may not support getAutoCommit() or setAutoCommit(). Requested setting: false.  Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 46.810.842 milliseconds ago.  The last packet sent successfully to the server was 46.810.842 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
   at org.apache.ibatis.transaction.jdbc.JdbcTransaction.setDesiredAutoCommit(JdbcTransaction.java:47)

This happens since I changed the way to config activiti.
At first I was using the properties file. Now I use a programmatic configuration as in the next code block.


public static void initActiviti() {
        try {
            //ProcessEngines.init();

            ProcessEngine processEngine = ProcessEngineConfiguration
                    .createStandaloneProcessEngineConfiguration()
                    .setJdbcUrl(ApplicationConfig.getConfigParam("activiti.url"))
                    .setJdbcDriver(ApplicationConfig.getConfigParam("activiti.driverClassName"))
                    .setJdbcUsername(ApplicationConfig.getEncryptedConfigParamDecrypted("activiti.username"))
                    .setJdbcPassword(ApplicationConfig.getEncryptedConfigParamDecrypted("activiti.password"))
                    .setJdbcMaxActiveConnections(Integer.parseInt(ApplicationConfig.getConfigParam("activiti.jdbcMaxActiveConnections")))
                    .setJdbcMaxIdleConnections(Integer.parseInt(ApplicationConfig.getConfigParam("activiti.jdbcMaxIdleConnections")))
                    .setDatabaseType(ApplicationConfig.getConfigParam("activiti.databaseType"))
                    .setDatabaseSchemaUpdate(ApplicationConfig.getConfigParam("activiti.databaseSchemaUpdate"))
                    .setHistory(ApplicationConfig.getConfigParam("activiti.history"))
                    .setProcessEngineName(ACTIVITI_ENGINE_NAME)
                    .buildProcessEngine();

            ProcessEngines.registerProcessEngine(processEngine);

//do deployments here
} catch (Exception e) {
            logger.log(Priority.FATAL, "Couldn't initialize Activiti Engine ", e);
        }

config params


<context-param>
        <param-name>activiti.url</param-name>
        <param-value>jdbc:mysql://localhost:3306/activiti?autoReconnect=true</param-value>
    </context-param>
    <context-param>
        <param-name>activiti.driverClassName</param-name>
        <param-value>com.mysql.jdbc.Driver</param-value>
    </context-param>

  ….

How to fix this? is this an ibatis issue or activiti?
2 REPLIES 2

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
A combination of both. Not all MyBatis db connection params can be configured via the programmatic way. Personally I'd stick with the config file way.

You miss some connection validity checking params now. See the MySQL driver config things to figure out which ones, or look in the config file you formerly used.

luisalves00
Champ in-the-making
Champ in-the-making
did some changes (need more time to know if it's working):


org.apache.commons.dbcp.BasicDataSource bds = new org.apache.commons.dbcp.BasicDataSource();
            bds.setDefaultAutoCommit(false); //as I had on the file

….

ProcessEngine processEngine = ProcessEngineConfiguration
                    .createStandaloneProcessEngineConfiguration().setDataSource(bds)

…..

Ronald, I'm using the programmatic way to obfuscate the Data Source credentials…