On a project using Camunda 7.22 (MyBatis 3.5.12) with a data source for Oracle 19c and with ojdbc11, jdk17, and tomcat 10. Mybatis reports a mapping error:
Caused by: org.apache.ibatis.reflection.ReflectionException: Could not set property ‘retriesFromPersistence’ of ‘class org.camunda.bpm.engine.impl.persistence.entity.MessageEntity’ with value ‘3’ Cause: java.lang.IllegalArgumentException: argument type mismatch
at org.apache.ibatis.reflection.wrapper.BeanWrapper.setBeanProperty(BeanWrapper.java:184)
at org.apache.ibatis.reflection.wrapper.BeanWrapper.set(BeanWrapper.java:58)
at org.apache.ibatis.reflection.MetaObject.setValue(MetaObject.java:139)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.applyPropertyMappings(DefaultResultSetHandler.java:508)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getRowValue(DefaultResultSetHandler.java:414)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValuesForSimpleResultMap(DefaultResultSetHandler.java:362)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValues(DefaultResultSetHandler.java:333)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSet(DefaultResultSetHandler.java:306)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSets(DefaultResultSetHandler.java:202)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:66)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:80)
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:65)
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:333)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:158)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:110)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:90)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:154)
… 25 common frames omitted
Caused by: java.lang.IllegalArgumentException: argument type mismatch
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
when calling select_job:
### The error may exist in org/camunda/bpm/engine/impl/mapping/entity/Job.xml
### The error may involve org.camunda.bpm.engine.impl.persistence.entity.JobEntity.selectJob
### The error occurred while handling results
### SQL: select * from ACTIVITI.T_NSR_ACT_RU_JOB where ID_ = ?
The database field RETRIES_ is type NUMBER(38,0) (Oracle corresponds to the data types: int, integer, smalint ) and declared as int in Camunda class Java source code. Unfortunately, we don’t have the control to modify Java types or queries on Camunda.
So I use solution wrappers to intercept and adapt JDBC calls :
In ResultSetWrapper, the method used by MyBatis or the Oracle JDBC driver for RETRIES_ field mapping is getBigDecimal(String), while it uses getInt(String) for the fields: REV_, SUSPENSION_STATE_
Even if I modify the SQL query in ConnectionWrapper to CAST(RETRIES_ AS integer), it always returns a BigDecimal.
The solution of intercepting getBigDecimal(String) in ResultSetWrapper by returning a BigDecimal constructed from an int doesn’t work either.
The problem lies entirely with MyBatis, which:
- Receives a BigDecimal (even a well-formed one),
- And attempts to inject it into a setRetriesFromPersistence(int) setter without an explicit conversion,
- Which causes an IllegalArgumentException.
How Can I resolve this ?