createGroovyScriptExpression for returning LocalDateTime

Hello, I’m trying to execute the following code:

`org.bonitasoft.engine.operation.OperationBuilder operationBuilder = new org.bonitasoft.engine.operation.OperationBuilder();

org.bonitasoft.engine.operation.Operation operation = operationBuilder.createBusinessDataSetAttributeOperation(dataBusinessName, operation, LocalDateTime.class.getName(),
new ExpressionBuilder()
.createGroovyScriptExpression(operation, “return java.time.LocalDateTime.now()”, LocalDateTime.class.getName()))`

The idea is to create a groovy script for returning a LocalDateTime value.

But I got the next error:

Caused by: org.bonitasoft.engine.exception.BonitaRuntimeException: USERNAME=XX| org.bonitasoft.engine.transaction.STransactionCommitException: javax.transaction.RollbackException: ARJUNA016053: Could not commit transaction. at org.bonitasoft.engine.api.HTTPServerAPI.invokeMethod(HTTPServerAPI.java:146) at org.bonitasoft.engine.api.impl.ClientInterceptor.invoke(ClientInterceptor.java:86) at com.sun.proxy.$Proxy71.updateActivityInstanceVariables(Unknown Source) ... at Caused by: javax.transaction.RollbackException.: ARJUNA016053: Could not commit transaction. ( ) at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1212) at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:126) at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:89) at org.bonitasoft.engine.transaction.JTATransactionServiceImpl.complete(JTATransactionServiceImpl.java:176) at ... 53 more. ( ) at Caused by: javax.persistence.PersistenceException.: org.hibernate.exception.DataException: could not execute statement ( ) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1763) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1677) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1683) at org.hibernate.jpa.spi.AbstractEntityManagerImpl$CallbackExceptionMapperImpl.mapManagedFlushFailure(AbstractEntityManagerImpl.java:1882) at org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorNonTrackingImpl.beforeCompletion(SynchronizationCallbackCoordinatorNonTrackingImpl.java:119) at org.hibernate.engine.transaction.synchronization.internal.RegisteredSynchronization.beforeCompletion(RegisteredSynchronization.java:50) at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:76) at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:368) at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:91) at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:162) at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1200) at ... 56 more. ( ) at Caused by: org.hibernate.exception.DataException.: could not execute statement ( ) at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:135) at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:126) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:112) at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:211) at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3285) at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:3183) at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3525) at org.hibernate.action.internal.EntityUpdateAction.execute(EntityUpdateAction.java:159) at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:465) at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:351) at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:350) at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:56) at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1258) at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:425) at org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorNonTrackingImpl.beforeCompletion(SynchronizationCallbackCoordinatorNonTrackingImpl.java:114) at ... 62 more. ( ) at Caused by: com.microsoft.sqlserver.jdbc.SQLServerException.: String or binary data would be truncated. ( ) at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216) at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1515) at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:404) at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:350) at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696) at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715) at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:180) at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:155) at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate(SQLServerPreparedStatement.java:314) at org.jboss.jca.adapters.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:537) at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:208)

Any idea, what’s happening?
I’m using Bonita 7.6.1

Hi Antoine,

First things first.
Thanks for your time and your answer.
And sorry for this late response.

We have an “inherited” process and we had to do some changes. During these changes, we’ve configured something wrong. We noticed it after an exhaustive checking. After doing the things right it worked.

So, Bonita works as expected.

I see that you are executing your code with SQL Server database. Did you try to run it inside Bonita Studio with the default h2 database?

Also can you give a little bit more context about why you are trying to define an operation programmatically?

Finally if you have a quick snippet of code to reproduce the issue I can test it on a more recent version of Bonita. I’m not aware of any issue related to LocalDateTime fixed after 7.6.1 but it worth a quick test.

Hi,

Thanks a lot for taking the time to share your feedback. Good to now that everything work as expected!