Problem getting CDI Injection working with Java Delegate under Wildfly

548 views
Skip to first unread message

kc7b...@gmail.com

unread,
Apr 22, 2015, 11:09:55 AM4/22/15
to camunda-...@googlegroups.com
I have a delegate that injects a custom data manager that includes the EntityManager:

@Named
public class MIRCompleteDelegate implements JavaDelegate {

@Inject
@SpecializedDataManager
private IRestEndpointDataManager restEndpointDataManager;

@Override
public void execute(DelegateExecution execution) throws Exception {
...
}
}

I have specified the org.camunda.bpm.container.impl.jboss.config.ManagedJtaProcessEngineConfiguration in the standalone.xml

I've also verified that the camunda-engine-cdi and camunda-ejb-client jars are in my war. I'm new to this and CDI. Can anyone give me some pointers as to where I may be going wrong?

David

Christian Lipphardt

unread,
Apr 22, 2015, 11:19:04 AM4/22/15
to camunda-...@googlegroups.com, kc7b...@gmail.com
Hi David,

I assume you are getting a NullPointerException error when you are trying to use the 'restEndpointDataManager' in your code inside the delegate. Am I right?
Are you using the JBoss/Wildfly distribution offered by camunda through our download site?

> I've also verified that the camunda-engine-cdi and camunda-ejb-client jars are in my war.
Looks good.

Question:
How do you reference the JavaDelegate in your bpmn process? Do you use correctly the 'camunda:delegateExpression="${mIRCompleteDelegate}"' as shown in [1]?

Cheers,
Christian

kc7b...@gmail.com

unread,
Apr 22, 2015, 11:23:43 AM4/22/15
to camunda-...@googlegroups.com, kc7b...@gmail.com
Thanks for the quick response. I am using the Camunda Wildfly distribution.

I am referencing the delegate as:

<bpmn2:serviceTask id="send_mir_done_service_task" camunda:class="com.orci.mir.bpm.camunda.svc.delegates.MIRCompleteDelegate" name="MIR Done">

Do I need to change to use an expression?
David

Christian Lipphardt

unread,
Apr 22, 2015, 11:46:32 AM4/22/15
to camunda-...@googlegroups.com, kc7b...@gmail.com
Hi David,

Yes, please reference it as 

<bpmn2:serviceTask id="send_mir_done_service_task" camunda:delegateExpression="${mIRCompleteDelegate}" name="MIR Done">

Please also read the linked docs about expression language usage[1] in Camunda BPM.

Cheers,
Christian

kc7b...@gmail.com

unread,
Apr 22, 2015, 12:04:25 PM4/22/15
to camunda-...@googlegroups.com, kc7b...@gmail.com
Thanks, that seems to have gotten the CDI to work. Now I am getting another error:

2015-04-22 12:04:15,805 WARN [com.arjuna.ats.arjuna] (pool-12-thread-1) ARJUNA012140: Adding multiple last resources is disallowed. Trying to add LastResourceRecord(XAOnePhaseResource(LocalXAResourceImpl@58bc357e[connectionListener=616891d4 connectionManager=1aa3e8b warned=false currentXid=< formatId=131077, gtrid_length=29, bqual_length=36, tx_uid=0:ffffac0d1e1d:-7448eb38:5537c661:de, node_name=1, branch_uid=0:ffffac0d1e1d:-7448eb38:5537c661:fb, subordinatenodename=null, eis_name=java:jboss/datasources/mir-DS > productName=PostgreSQL productVersion=9.4.1 jndiName=java:jboss/datasources/mir-DS])), but already have LastResourceRecord(XAOnePhaseResource(LocalXAResourceImpl@36b10276[connectionListener=6cb924c1 connectionManager=5986c223 warned=false currentXid=< formatId=131077, gtrid_length=29, bqual_length=36, tx_uid=0:ffffac0d1e1d:-7448eb38:5537c661:de, node_name=1, branch_uid=0:ffffac0d1e1d:-7448eb38:5537c661:e0, subordinatenodename=null, eis_name=java:jboss/datasources/ProcessEngine > productName=PostgreSQL productVersion=9.4.1 jndiName=java:jboss/datasources/ProcessEngine]))
2015-04-22 12:04:15,810 WARN [com.arjuna.ats.jta] (pool-12-thread-1) ARJUNA016087: TransactionImple.delistResource - unknown resource
2015-04-22 12:04:15,812 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (pool-12-thread-1) SQL Error: 0, SQLState: null
2015-04-22 12:04:15,812 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (pool-12-thread-1) javax.resource.ResourceException: IJ000457: Unchecked throwable in managedConnectionReconnected() cl=org.jboss.jca.core.connectionmanager.listener.TxConnectionListener@616891d4[state=NORMAL managed connection=org.jboss.jca.adapters.jdbc.local.LocalManagedConnection@3fa760ec connection handles=0 lastUse=1429718655811 trackByTx=false pool=org.jboss.jca.core.connectionmanager.pool.strategy.OnePool@16474d98 mcp=SemaphoreArrayListManagedConnectionPool@5e77e9ad[pool=mir] xaResource=LocalXAResourceImpl@58bc357e[connectionListener=616891d4 connectionManager=1aa3e8b warned=false currentXid=null productName=PostgreSQL productVersion=9.4.1 jndiName=java:jboss/datasources/mir-DS] txSync=null]
2015-04-22 12:04:15,817 ERROR [stderr] (pool-12-thread-1) javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Could not open connection

My guess is there is something wrong with Camunda and my code not properly sharing the EntityManager or the transaction manager. Any ideas?
David

Christian Lipphardt

unread,
Apr 22, 2015, 12:33:04 PM4/22/15
to camunda-...@googlegroups.com, kc7b...@gmail.com
Hi David,

Please always provide complete stacktraces / server logs. I can only see 
Do you use 2 datasources (Camunda BPM DS + own datasource eg. some JPA stuff) in your process application? If so, please configure both to be XA datasources. Please consult Wildfly documentation on how to do this.
An example from our QA test suite can be seen here [1].

Cheers,
Christian

kc7b...@gmail.com

unread,
Apr 22, 2015, 1:10:17 PM4/22/15
to camunda-...@googlegroups.com, kc7b...@gmail.com
Thanks, when I set my xa-datasource like the example, I get the error:

2015-04-22 12:56:23,124 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 30) JBAS014613: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("jdbc-driver" => "postgresql")
]) - failure description: "JBAS010441: Failed to load module for driver [org.postgresql.postgresql]"


Is there something I need in my wildfly modules directory? David

kc7b...@gmail.com

unread,
Apr 22, 2015, 1:54:25 PM4/22/15
to camunda-...@googlegroups.com, kc7b...@gmail.com
OK, I fixed the org.postgresql.postgresql module and now it works!!!

One more thing, When I try to run with unit tests I get the error:

Unknown property used in expression: ${MIRCompleteDelegate}. Cause: Cannot resolve identifier 'MIRCompleteDelegate'

My unit tests extends ProcessEngineTestCase. It seems that it is not processing the @Named annotation on the delegate class. Is there some way I need to let ProcessEngineTestCase know about my named delegates?

David

Christian Lipphardt

unread,
Apr 22, 2015, 3:15:49 PM4/22/15
to camunda-...@googlegroups.com
Hi David,

For Unit testing you could use the Camunda Engine CDI module test base class[1] as an example.
It bootstraps the engine through a @ProcessEngineRule combined with a camunda.cfg.xml [2] and runs the unit tests using the test framework Arquillian[3] to bootstrap a CDI container. (Weld in this case)

But it is not easily possible to bootstrap an EntityManager in this unit test environment. Most people tend to use Arquillian and execute the tests on the real app server. An example for this arquillian testing can be found inside the Camunda Maven Archetype[4].

Cheers,
Christian



David

--
You received this message because you are subscribed to the Google Groups "camunda BPM users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camunda-bpm-us...@googlegroups.com.
To post to this group, send email to camunda-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/camunda-bpm-users/49d17e09-7b2e-4586-a9c5-47e379bc5190%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages