BDM and Groovy script

I use the following Groovy script to retrieve data stored in the BDM. In the BDM I defined a “business Object” called “Rutas” that has two “attributes”, “nombreRuta” and “valor”.
The script I use is:

import com.company.model.Rutas
List rtSubir = rutasDAO.findByNombreRuta("rutaSubir",0,100)

return rtSubir

But I fails. I think that left me something, but I can not to find out what it is.
Any suggestions?. Thank you.

What does your log say?

Also, where are you using the output of this script?
Is it in an operation bound to a BDM object?

Sorry. I have not seen the reviews until today. I can not find the log. Simply fails the connector.
During these weeks I’ve done more tests, all without success.
For example, if I want to access a stored value in the BDM I know your idPersistence:

`import com.company.model.Rutas
import com.company.model.RutasDAO;

long myId = long.valueOf("1")

Rutas rutModificar = rutasDAO.findByPersistenceId(myId)`

Neither works.
I understand there something I’m doing wrong. Thanks.

I found the log.

Grave: THREAD_ID=1157 | HOSTNAME=javier-HP | TENANT_ID=1 | The work [ExecuteConnectorOfActivity: flowNodeInstanceId = 120082, connectorDefinitionName = actualizar] failed. The failure will be handled.
2015-09-24 21:15:36.338 +0200 org.bonitasoft.engine.execution.work.FailureHandlingBonitaWork org.bonitasoft.engine.log.technical.TechnicalLoggerSLF4JImpl log
Grave: THREAD_ID=1157 | HOSTNAME=javier-HP | TENANT_ID=1 | org.bonitasoft.engine.core.connector.exception.SConnectorException : “PROCESS_DEFINITION_ID=4823618982317378403 | PROCESS_NAME=introducir datos | PROCESS_VERSION=1.0 | PROCESS_INSTANCE_ID=6029 | ROOT_PROCESS_INSTANCE_ID=6029 | FLOW_NODE_DEFINITION_ID=4758779808554285708 | FLOW_NODE_INSTANCE_ID=120082 | FLOW_NODE_NAME=Step1 | CONNECTOR_DEFINITION_IMPLEMENTATION_CLASS_NAME=actualizar | CONNECTOR_INSTANCE_ID=60019 | org.bonitasoft.engine.connector.exception.SConnectorException: java.util.concurrent.ExecutionException: org.bonitasoft.engine.commons.exceptions.SBonitaRuntimeException: java.lang.IllegalStateException: org.bonitasoft.engine.transaction.STransactionNotFoundException: No active transaction.”
org.bonitasoft.engine.core.connector.exception.SConnectorException: PROCESS_DEFINITION_ID=4823618982317378403 | PROCESS_NAME=introducir datos | PROCESS_VERSION=1.0 | PROCESS_INSTANCE_ID=6029 | ROOT_PROCESS_INSTANCE_ID=6029 | FLOW_NODE_DEFINITION_ID=4758779808554285708 | FLOW_NODE_INSTANCE_ID=120082 | FLOW_NODE_NAME=Step1 | CONNECTOR_DEFINITION_IMPLEMENTATION_CLASS_NAME=actualizar | CONNECTOR_INSTANCE_ID=60019 | org.bonitasoft.engine.connector.exception.SConnectorException: java.util.concurrent.ExecutionException: org.bonitasoft.engine.commons.exceptions.SBonitaRuntimeException: java.lang.IllegalStateException: org.bonitasoft.engine.transaction.STransactionNotFoundException: No active transaction.
at org.bonitasoft.engine.core.connector.impl.ConnectorServiceImpl.executeConnectorInClassloader(ConnectorServiceImpl.java:325)
at org.bonitasoft.engine.core.connector.impl.ConnectorServiceImpl.executeConnector(ConnectorServiceImpl.java:143)
at org.bonitasoft.engine.connector.ConnectorServiceDecorator.executeConnector(ConnectorServiceDecorator.java:111)
at org.bonitasoft.engine.execution.work.ExecuteConnectorWork.work(ExecuteConnectorWork.java:131)
at org.bonitasoft.engine.execution.work.failurewrapping.TxInHandleFailureWrappingWork.work(TxInHandleFailureWrappingWork.java:42)
at org.bonitasoft.engine.execution.work.failurewrapping.TxInHandleFailureWrappingWork.work(TxInHandleFailureWrappingWork.java:42)
at org.bonitasoft.engine.execution.work.failurewrapping.TxInHandleFailureWrappingWork.work(TxInHandleFailureWrappingWork.java:42)
at org.bonitasoft.engine.execution.work.failurewrapping.TxInHandleFailureWrappingWork.work(TxInHandleFailureWrappingWork.java:42)
at org.bonitasoft.engine.execution.work.FailureHandlingBonitaWork.work(FailureHandlingBonitaWork.java:66)
at org.bonitasoft.engine.work.BonitaWork.run(BonitaWork.java:56)
at org.bonitasoft.engine.work.SequenceRunnableExecutor.innerRun(SequenceRunnableExecutor.java:47)
at org.bonitasoft.engine.work.BonitaRunnable.run(BonitaRunnable.java:35)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.bonitasoft.engine.connector.exception.SConnectorException: java.util.concurrent.ExecutionException: org.bonitasoft.engine.commons.exceptions.SBonitaRuntimeException: java.lang.IllegalStateException: org.bonitasoft.engine.transaction.STransactionNotFoundException: No active transaction.
at org.bonitasoft.engine.connector.impl.ConnectorExecutorImpl.execute(ConnectorExecutorImpl.java:128)
at org.bonitasoft.engine.core.connector.impl.ConnectorServiceImpl.executeConnectorInClassloader(ConnectorServiceImpl.java:317)
… 14 more
Caused by: java.util.concurrent.ExecutionException: org.bonitasoft.engine.commons.exceptions.SBonitaRuntimeException: java.lang.IllegalStateException: org.bonitasoft.engine.transaction.STransactionNotFoundException: No active transaction.
at java.util.concurrent.FutureTask.report(Unknown Source)
at java.util.concurrent.FutureTask.get(Unknown Source)
at org.bonitasoft.engine.connector.impl.ConnectorExecutorImpl.getValue(ConnectorExecutorImpl.java:152)
at org.bonitasoft.engine.connector.impl.ConnectorExecutorImpl.execute(ConnectorExecutorImpl.java:122)
… 15 more
Caused by: org.bonitasoft.engine.commons.exceptions.SBonitaRuntimeException: java.lang.IllegalStateException: org.bonitasoft.engine.transaction.STransactionNotFoundException: No active transaction.
at com.company.model.server.RutasDAOImpl.findByPersistenceId(RutasDAOImpl.java:29)
at com.company.model.RutasDAO$findByPersistenceId.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at Script1.run(Script1.groovy:23)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:580)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:618)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:589)
at org.bonitasoft.connectors.scripting.GroovyScriptConnector.executeBusinessLogic(GroovyScriptConnector.java:48)
at org.bonitasoft.engine.connector.AbstractConnector.execute(AbstractConnector.java:77)
at org.bonitasoft.engine.core.connector.impl.SConnectorAdapter.execute(SConnectorAdapter.java:69)
at org.bonitasoft.engine.connector.impl.ConnectorExecutorImpl$ExecuteConnectorCallable.call(ConnectorExecutorImpl.java:208)
at org.bonitasoft.engine.connector.impl.ConnectorExecutorImpl$ExecuteConnectorCallable.call(ConnectorExecutorImpl.java:179)
at java.util.concurrent.FutureTask.run(Unknown Source)
… 3 more
Caused by: java.lang.IllegalStateException: org.bonitasoft.engine.transaction.STransactionNotFoundException: No active transaction.
at org.bonitasoft.engine.business.data.impl.JPABusinessDataRepositoryImpl.getEntityManager(JPABusinessDataRepositoryImpl.java:123)
at org.bonitasoft.engine.business.data.impl.JPABusinessDataRepositoryImpl.findByNamedQuery(JPABusinessDataRepositoryImpl.java:209)
at com.company.model.server.RutasDAOImpl.findByPersistenceId(RutasDAOImpl.java:27)
… 17 more
Caused by: org.bonitasoft.engine.transaction.STransactionNotFoundException: No active transaction.
at org.bonitasoft.engine.transaction.JTATransactionServiceImpl.registerBonitaSynchronization(JTATransactionServiceImpl.java:286)
at org.bonitasoft.engine.business.data.impl.JPABusinessDataRepositoryImpl.getEntityManager(JPABusinessDataRepositoryImpl.java:121)
… 19 more

Using a DAO in a connector is not supported as:

  • accessing a DAO requires the use of a DB transaction
  • for performance reasons connectors are executed outside of transactions

We will update our documentation to be clearer on that limitation.

In order to bypass this limitation, you should use an operation to execute your Groovy script with the DAO calls.

Thanks for the clarification. This will allow me to not spend more time on that line

Hi,

Is there any other way wherein i can get the value of data in bdm. My purpose is to create a sequential number per company.

Thanks