Wrong length calculation for an i18n string in JDBC repository schema in JBeret

Solution Unverified - Updated

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP) 7.0

Issue

  • An error when using the Batch API with a JDBC repository.
ERROR [org.jberet] (Batch Thread - 1) JBERET000007: Failed to run job in_out_file_test_0015, , org.jberet.job.model.Job@dbfbdf19: javax.batch.operations.BatchRuntimeException: JBERET000626: Failed to run UPDATE STEP_EXECUTION SET ENDTIME=?, BATCHSTATUS=?, EXITSTATUS=?, EXECUTIONEXCEPTION=?, PERSISTENTUSERDATA=?, READCOUNT=?, WRITECOUNT=?, COMMITCOUNT=?, ROLLBACKCOUNT=?, READSKIPCOUNT=?, PROCESSSKIPCOUNT=?, FILTERCOUNT=?, WRITESKIPCOUNT=?, READERCHECKPOINTINFO=?, WRITERCHECKPOINTINFO=? WHERE STEPEXECUTIONID=?
        at org.jberet.repository.JdbcRepository.updateStepExecution(JdbcRepository.java:673)
        at org.jberet.repository.JdbcRepository.savePersistentData(JdbcRepository.java:685)
        at org.wildfly.extension.batch.jberet.job.repository.JobRepositoryService.savePersistentData(JobRepositoryService.java:189)
        at org.wildfly.extension.batch.jberet.job.repository.JdbcJobRepositoryService.savePersistentData(JdbcJobRepositoryService.java:44)
        at org.jberet.runtime.context.StepContextImpl.savePersistentData(StepContextImpl.java:190)
        at org.jberet.runtime.runner.StepExecutionRunner.run(StepExecutionRunner.java:165)
        at org.jberet.runtime.runner.CompositeExecutionRunner.runStep(CompositeExecutionRunner.java:164)
        at org.jberet.runtime.runner.CompositeExecutionRunner.runFromHeadOrRestartPoint(CompositeExecutionRunner.java:88)
        at org.jberet.runtime.runner.JobExecutionRunner.run(JobExecutionRunner.java:59)
        at org.wildfly.extension.batch.jberet.impl.BatchEnvironmentService$WildFlyBatchEnvironment$1.run(BatchEnvironmentService.java:243)
        at org.wildfly.extension.requestcontroller.RequestController$QueuedTask$1.run(RequestController.java:497)
        at org.jberet.spi.JobExecutor$3.run(JobExecutor.java:161)
        at org.jberet.spi.JobExecutor$1.run(JobExecutor.java:99)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
        at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: java.sql.SQLException: ORA-12899: ...

Resolution

For Oracle DB, it can change the string length semantics, NLS_LENGTH_SEMANTICS, per session. And EAP's <datasource> can execute an SQL statement against connections in its pool by <new-connection-sql>. Hence define the following element in your <datasource> of the JDBC repository.

<new-connection-sql>ALTER SESSION SET NLS_LENGTH_SEMANTICS = 'CHAR'</new-connection-sql>

Root Cause

This is a bug of JBERET-3501 that the database scheme is not considering i18n text. It will be fixed in the future version of JBeret an will be incorporated to EAP.

Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.