Error trying to access the BDM

I’m trying to access the BDM from a script in Groovy. After several attempts and tests can not I find what is wrong. Attached diagram and log.

DAO_error

2015-09-25 11:04:26.595 +0200 org.bonitasoft.engine.api.impl.ProcessAPIImpl org.bonitasoft.engine.log.technical.TechnicalLoggerSLF4JImpl log
Información: THREAD_ID=66 | HOSTNAME=javier-HP | TENANT_ID=1 | The user <william.jobs> has installed process <DAO_error> in version <1.0> with id <8142357218087594910>
2015-09-25 11:04:26.680 +0200 org.bonitasoft.engine.api.impl.transaction.process.EnableProcess org.bonitasoft.engine.log.technical.TechnicalLoggerSLF4JImpl log
Información: THREAD_ID=66 | HOSTNAME=javier-HP | TENANT_ID=1 | The user <william.jobs> has enabled process <DAO_error> in version <1.0> with id <8142357218087594910>
2015-09-25 11:04:29.124 +0200 org.bonitasoft.engine.api.impl.ProcessStarter org.bonitasoft.engine.log.technical.TechnicalLoggerSLF4JImpl log
Información: THREAD_ID=64 | HOSTNAME=javier-HP | TENANT_ID=1 | The user <william.jobs> has started the process instance <8003> of process <DAO_error> in version <1.0> and id <8142357218087594910>
2015-09-25 11:04:29.199 +0200 org.bonitasoft.engine.execution.work.FailureHandlingBonitaWork org.bonitasoft.engine.log.technical.TechnicalLoggerSLF4JImpl log
Grave: THREAD_ID=119 | HOSTNAME=javier-HP | TENANT_ID=1 | The work [ExecuteConnectorOfActivity: flowNodeInstanceId = 160007, connectorDefinitionName = prueba] failed. The failure will be handled.
2015-09-25 11:04:29.218 +0200 org.bonitasoft.engine.execution.work.FailureHandlingBonitaWork org.bonitasoft.engine.log.technical.TechnicalLoggerSLF4JImpl log
Grave: THREAD_ID=119 | HOSTNAME=javier-HP | TENANT_ID=1 | org.bonitasoft.engine.core.connector.exception.SConnectorException : “PROCESS_DEFINITION_ID=8142357218087594910 | PROCESS_NAME=DAO_error | PROCESS_VERSION=1.0 | PROCESS_INSTANCE_ID=8003 | ROOT_PROCESS_INSTANCE_ID=8003 | FLOW_NODE_DEFINITION_ID=8574155469211731726 | FLOW_NODE_INSTANCE_ID=160007 | FLOW_NODE_NAME=Step3 | CONNECTOR_DEFINITION_IMPLEMENTATION_CLASS_NAME=prueba | CONNECTOR_INSTANCE_ID=100003 | 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=8142357218087594910 | PROCESS_NAME=DAO_error | PROCESS_VERSION=1.0 | PROCESS_INSTANCE_ID=8003 | ROOT_PROCESS_INSTANCE_ID=8003 | FLOW_NODE_DEFINITION_ID=8574155469211731726 | FLOW_NODE_INSTANCE_ID=160007 | FLOW_NODE_NAME=Step3 | CONNECTOR_DEFINITION_IMPLEMENTATION_CLASS_NAME=prueba | CONNECTOR_INSTANCE_ID=100003 | 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:11)
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

philippe.ozil has responded to another post explaining that it is not possible to use DAO in a groovy connector.

[http://community.bonitasoft.com/questions-and-answers/bdm-and-groovy-script]
[http://community.bonitasoft.com/questions-and-answers/bdm-and-groovy-script]: http://community.bonitasoft.com/questions-and-answers/bdm-and-groovy-script