1 2 Previous Next 16 Replies Latest reply on Apr 11, 2013 5:14 AM by Łukasz Dywicki

    How to configure transaction manager with JPA Binding

    Jeff DeLong Master

      I have an issue with the JPA Binding in SwitchYard. Even though my configuration similar to the quickstart:

       

         <sca:reference name="PolicyQuoteEntityService" multiplicity="0..1" promote="PolicyQuoteProcess/PolicyQuoteEntityService">

            <sca:interface.java interface="org.acme.insurance.PolicyQuoteEntityService.PolicyQuoteEntityService"/>

            <jpa:binding.jpa>

              <jpa:contextMapper/>

              <jpa:entityClassName>org.acme.insurance.PolicyQuote</jpa:entityClassName>

              <jpa:persistenceUnit>org.jbpm.persistence.jpa</jpa:persistenceUnit>

              <jpa:transactionManager>#jtaTransactionManager</jpa:transactionManager>

           </jpa:binding.jpa>

          </sca:reference>

       

      I get the following exception:

       

      org.switchyard.HandlerException: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: jpa://org.acme.insurance.PolicyQuote?persistenceUnit=org.jbpm.persistence.jpa&transactionManager=%23jtaTransactionManager due to: Could not find a suitable setter for property: transactionManager as there isn't a setter method with same type: java.lang.String nor type conversion possible: No type converter available to convert from type: java.lang.String to the required type: org.springframework.transaction.PlatformTransactionManager with value #jtaTransactionManager

      --- Caused by org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: jpa://org.acme.insurance.PolicyQuote?persistenceUnit=org.jbpm.persistence.jpa&transactionManager=%23jtaTransactionManager due to: Could not find a suitable setter for property: transactionManager as there isn't a setter method with same type: java.lang.String nor type conversion possible: No type converter available to convert from type: java.lang.String to the required type: org.springframework.transaction.PlatformTransactionManager with value #jtaTransactionManager

      --- Caused by java.lang.IllegalArgumentException: Could not find a suitable setter for property: transactionManager as there isn't a setter method with same type: java.lang.String nor type conversion possible: No type converter available to convert from type: java.lang.String to the required type: org.springframework.transaction.PlatformTransactionManager with value #jtaTransactionManager

      ------ End Message Trace -------

      13:50:40,899 ERROR [org.switchyard.component.bpm.service.SwitchYardServiceWorkItemHandler] (http-localhost-127.0.0.1-8080-1) Fault encountered: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: jpa://org.acme.insurance.PolicyQuote?persistenceUnit=org.jbpm.persistence.jpa&transactionManager=%23jtaTransactionManager due to: Could not find a suitable setter for property: transactionManager as there isn't a setter method with same type: java.lang.String nor type conversion possible: No type converter available to convert from type: java.lang.String to the required type: org.springframework.transaction.PlatformTransactionManager with value #jtaTransactionManager: org.switchyard.HandlerException: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: jpa://org.acme.insurance.PolicyQuote?persistenceUnit=org.jbpm.persistence.jpa&transactionManager=%23jtaTransactionManager due to: Could not find a suitable setter for property: transactionManager as there isn't a setter method with same type: java.lang.String nor type conversion possible: No type converter available to convert from type: java.lang.String to the required type: org.springframework.transaction.PlatformTransactionManager with value #jtaTransactionManager

        

       

      What should be the value for the TransactionManager?

        • 1. Re: How to configure transaction manager with JPA Binding
          Łukasz Dywicki Novice

          Hey Jeff,

          That's really strange. We do have #jtaTransactionManager used in our quickstarts and it works. Bean with name "jtaTransactionManager" is put to registry by org.switchyard.component.camel.common.handler.InboundHandler and created by org.switchyard.component.camel.common.transaction.TransactionManagerFactory. Not sure why it doesn't work in your case. Can you attach your application or debug TransactionManagerFactory.create method?

          • 2. Re: How to configure transaction manager with JPA Binding
            Łukasz Dywicki Novice

            Hey Jeff,
            I checked the code and there is a case we didn't cover. The TransactionManager bean is put into registry only if you use consumer and you set transaction manager property. We have no check for reference side to put transaction manager bean. That's a bug to be fixed in 1.0.

             

            The good sign is that you may walk around problem. Just create dummy service binding which will poll another persistence unit with empty database.

             

                    <!-- part to be added in META-INF/switchyard.xml -->
                    <sca:service name="FOO" promote="Dummy/Dummy">
                       <sca:interface.java interface="org.acme.insurance.PolicyQuoteEntityService.PolicyQuoteEntityService"/>
                       <jpa:binding.jpa>
                         <jpa:contextMapper/>
                         <jpa:entityClassName>org.acme.insurance.PolicyQuote</jpa:entityClassName>
                         <jpa:persistenceUnit>org.jbpm.persistence.jpa2</jpa:persistenceUnit>
                         <jpa:transactionManager>#jtaTransactionManager</jpa:transactionManager>
                       </jpa:binding.jpa>
                    </sca:service>
            

             

             

            <?xml version="1.0" encoding="UTF-8"?>
            <persistence
                version="1.0"
                xsi:schemaLocation=
                    "http://java.sun.com/xml/ns/persistence
            http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd
            http://java.sun.com/xml/ns/persistence/orm
            http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
                xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xmlns="http://java.sun.com/xml/ns/persistence">
            
                 <persistence-unit name="org.jbpm.persistence.jpa" transaction-type="JTA">
                     <jta-data-source>java:jboss/datasources/jbpmDS</jta-data-source>
                     <!-- first persistence unit -->
            
                 </persistence-unit>
            
                <persistence-unit name="org.jbpm.persistence.jpa2" transaction-type="JTA">
                    <jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source><!-- this is another JTA datasource which is enabled by default -->
                    <!-- here is same or different config -->
            
                </persistence-unit>
                
            </persistence>
            
            
            • 3. Re: How to configure transaction manager with JPA Binding
              Łukasz Dywicki Novice

              Quick and simple work around is to use CDI bean, then you need use #springPlatformTransactionManager as transaction manager name. You may also name it jtaTransactionManager - in this case this bean will override default bean created by InboundHandler.

               

              package org.acme;
              
              import javax.enterprise.inject.Produces;
              import javax.inject.Named;
              import javax.transaction.UserTransaction;
              
              import org.springframework.transaction.PlatformTransactionManager;
              import org.springframework.transaction.jta.JtaTransactionManager;
              
              import com.google.inject.Inject;
              
              public class TransactionManagerProducer {
              
                  @Inject @Produces @Named("springPlatformTransactionManager")
                  public PlatformTransactionManager create(UserTransaction ut) {
                      return new JtaTransactionManager(ut);
                  }
              
              }
              
              • 4. Re: How to configure transaction manager with JPA Binding
                Jeff DeLong Master

                Thanks, I will try to use one of your suggested workarounds for now.

                 

                This is a good reason to have two quickstarts, a producer and a consumer. I have mentioned before I thought the single quickstart showing both capabilties was bit confusing. It seems like if there were two quickstarts, this issue would have been uncovered much sooner.

                • 5. Re: How to configure transaction manager with JPA Binding
                  Jeff DeLong Master

                  I added the extra persistance unit and service and re-tested and the original service is working now. Thanks.

                  • 6. Re: How to configure transaction manager with JPA Binding
                    michael melsen Newbie

                    Hi guys,

                     

                    Hope you don't mind joining this thread and if you do, please move it to another thread . I've ran into the same problem I think and need some help. What I'm trying to accomplish is to combine the camel-mail-binding and the camel-jpa-binding quickstart. I want to accept an email (which works perfectly in switchyard) extract the content in a bean and then, from that bean, invoke the jpa component which basically uses the same configuration as the camel-jpa-binding quickstart except that it uses an actual database connection for db2.

                     

                    As stated in this thread I needed to add another dummy service with a jpa binding to work around this problem. It helps me a bit further, but now switchyard comes up with this exception:

                     

                    java.lang.Exception: org.switchyard.exception.SwitchYardException: org.switchyard.exception.SwitchYardException: Could not create a JtaTransactionManager as no TransactionManager was found in JNDI. Tried [java:jboss/UserTransaction, java:comp/UserTransaction]

                        at org.switchyard.test.SwitchYardRunner.createTest(SwitchYardRunner.java:69)

                        at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:236)

                        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)

                        at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:233)

                        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)

                        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)

                        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)

                        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)

                        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)

                        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)

                        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)

                        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)

                        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)

                        at org.junit.runners.ParentRunner.run(ParentRunner.java:300)

                        at org.switchyard.test.SwitchYardRunner.run(SwitchYardRunner.java:90)

                        at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)

                        at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

                        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)

                        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)

                        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)

                        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

                    Caused by: org.switchyard.exception.SwitchYardException: org.switchyard.exception.SwitchYardException: Could not create a JtaTransactionManager as no TransactionManager was found in JNDI. Tried [java:jboss/UserTransaction, java:comp/UserTransaction]

                        at org.switchyard.component.camel.common.handler.InboundHandler.<init>(InboundHandler.java:77)

                        at org.switchyard.component.camel.common.deploy.BaseBindingActivator.createInboundHandler(BaseBindingActivator.java:71)

                        at org.switchyard.component.camel.common.deploy.BaseBindingActivator.activateBinding(BaseBindingActivator.java:63)

                        at org.switchyard.deploy.internal.Deployment.deployServiceBindings(Deployment.java:515)

                        at org.switchyard.deploy.internal.Deployment.start(Deployment.java:141)

                        at org.switchyard.test.SwitchYardTestKit.deploy(SwitchYardTestKit.java:277)

                        at org.switchyard.test.SwitchYardTestKit.start(SwitchYardTestKit.java:180)

                        at org.switchyard.test.SwitchYardRunner.createTest(SwitchYardRunner.java:65)

                        ... 20 more

                    Caused by: org.switchyard.exception.SwitchYardException: Could not create a JtaTransactionManager as no TransactionManager was found in JNDI. Tried [java:jboss/UserTransaction, java:comp/UserTransaction]

                        at org.switchyard.component.camel.common.transaction.TransactionManagerFactory.create(TransactionManagerFactory.java:86)

                        at org.switchyard.component.camel.common.handler.InboundHandler.addTransactionPolicy(InboundHandler.java:126)

                        at org.switchyard.component.camel.common.handler.InboundHandler.createRouteDefinition(InboundHandler.java:92)

                        at org.switchyard.component.camel.common.handler.InboundHandler.<init>(InboundHandler.java:75)

                        ... 27 more

                     

                     

                    So what I did is add in my test the transactionMixIn that is also used in the camel-jpa-binding test, resulting in the following code:

                     

                    @SwitchYardTestCaseConfig(

                        config = SwitchYardTestCaseConfig.SWITCHYARD_XML,

                        mixins = {CDIMixIn.class,  TransactionMixIn.class}

                    )

                    @RunWith(SwitchYardRunner.class)

                     

                    However if I run the test now with this transaction mixin I get:

                     

                    WELD-000604 interface org.switchyard.component.bean.Reference is not declared @Target(METHOD, FIELD, PARAMETER, TYPE). Weld will use this annotation, however this may make the application unportable.

                     

                    and the following stacktrace:

                     

                    java.lang.NoSuchMethodError: org.jboss.logging.Logger.getMessageLogger(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Object;

                        at com.arjuna.ats.arjuna.logging.tsLogger.<clinit>(tsLogger.java:39)

                        at com.arjuna.ats.internal.arjuna.common.ClassloadingUtility.loadClass(ClassloadingUtility.java:78)

                        at com.arjuna.ats.internal.arjuna.common.ClassloadingUtility.loadAndInstantiateClass(ClassloadingUtility.java:119)

                        at com.arjuna.ats.jta.common.JTAEnvironmentBean.getTransactionManager(JTAEnvironmentBean.java:163)

                        at org.switchyard.component.test.mixins.transaction.TransactionMixIn.initialize(TransactionMixIn.java:80)

                        at org.switchyard.test.SwitchYardTestKit.initializeMixIns(SwitchYardTestKit.java:779)

                        at org.switchyard.test.SwitchYardTestKit.<init>(SwitchYardTestKit.java:170)

                        at org.switchyard.test.SwitchYardRunner.createTest(SwitchYardRunner.java:58)

                        at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:236)

                        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)

                        at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:233)

                        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)

                        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)

                        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)

                        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)

                        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)

                        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)

                        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)

                        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)

                        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)

                        at org.junit.runners.ParentRunner.run(ParentRunner.java:300)

                        at org.switchyard.test.SwitchYardRunner.run(SwitchYardRunner.java:90)

                        at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)

                        at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

                        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)

                        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)

                        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)

                        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

                     

                    any ideas where it might go wrong here?

                     

                    regards,

                     

                    Michael

                    • 7. Re: How to configure transaction manager with JPA Binding
                      michael melsen Newbie

                      Just an update, figured out that I had incorect dependencies. Changed

                       

                      <dependency>
                      <groupId>org.hibernate</groupId>
                      <artifactId>hibernate-core</artifactId>
                      <version>3.6.6.Final</version>
                      </dependency>

                       

                      to

                       

                      <dependency>
                      <groupId>org.hibernate</groupId>
                      <artifactId>hibernate-core</artifactId>
                      <version>3.6.6.Final</version>
                      </dependency>

                       

                      and added

                       

                      <dependency>
                      <groupId>org.hibernate</groupId>
                      <artifactId>hibernate-entitymanager</artifactId>
                      <version>4.0.1.Final</version>
                      <scope>compile</scope>
                      </dependency>

                       

                      This got me around the nosuchmethoderror as described above.

                       

                      The good news is that I actually see that the jpa binding works and the data is persisted to the database. That is great. The only downside is that it seems that the 'workaround' with the extra persistence unit keeps looping exceptions as it is not getting a transaction. The following stacktrace shows the jpa call with the dummy persistenceunit named org.jbpm.persistence.jpa2:

                       

                      09:54:27,484 DEBUG Camel (camel-1) thread #2 - jpa://nl.surf.domain.studielink.todo.TodoZGW [org.springframework.orm.jpa.EntityManagerFactoryUtils] Closing JPA EntityManager

                      09:54:27,484 DEBUG Camel (camel-1) thread #2 - jpa://nl.surf.domain.studielink.todo.TodoZGW [org.hibernate.engine.jdbc.internal.LogicalConnectionImpl] Releasing JDBC connection

                      09:54:27,484 DEBUG Camel (camel-1) thread #2 - jpa://nl.surf.domain.studielink.todo.TodoZGW [org.hibernate.engine.jdbc.internal.LogicalConnectionImpl] Released JDBC connection

                      09:54:27,484 DEBUG Camel (camel-1) thread #2 - jpa://nl.surf.domain.studielink.todo.TodoZGW [org.hibernate.engine.jdbc.internal.proxy.ConnectionProxyHandler] HHH000163: Logical connection releasing its physical connection

                      09:54:27,484 DEBUG Camel (camel-1) thread #2 - jpa://nl.surf.domain.studielink.todo.TodoZGW [org.springframework.transaction.jta.JtaTransactionManager] Initiating transaction rollback

                      09:54:27,494 WARN  Camel (camel-1) thread #2 - jpa://nl.surf.domain.studielink.todo.TodoZGW [org.apache.camel.impl.DefaultPollingConsumerPollStrategy] Consumer Consumer[jpa://nl.surf.domain.studielink.todo.TodoZGW?persistenceUnit=org.jbpm.persistence.jpa2&transactionManager=%23jtaTransactionManager] could not poll endpoint: Endpoint[jpa://nl.surf.domain.studielink.todo.TodoZGW?persistenceUnit=org.jbpm.persistence.jpa2&transactionManager=%23jtaTransactionManager] caused by: no transaction is in progress; nested exception is javax.persistence.TransactionRequiredException: no transaction is in progress

                      org.springframework.dao.InvalidDataAccessApiUsageException: no transaction is in progress; nested exception is javax.persistence.TransactionRequiredException: no transaction is in progress

                          at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:316)

                          at org.springframework.orm.jpa.DefaultJpaDialect.translateExceptionIfPossible(DefaultJpaDialect.java:120)

                          at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213)

                          at org.springframework.orm.jpa.JpaAccessor.translateIfNecessary(JpaAccessor.java:152)

                          at org.springframework.orm.jpa.JpaTemplate.execute(JpaTemplate.java:188)

                          at org.springframework.orm.jpa.JpaTemplate.execute(JpaTemplate.java:146)

                          at org.apache.camel.component.jpa.JpaTemplateTransactionStrategy$1.doInTransaction(JpaTemplateTransactionStrategy.java:80)

                          at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)

                          at org.apache.camel.component.jpa.JpaTemplateTransactionStrategy.execute(JpaTemplateTransactionStrategy.java:78)

                          at org.apache.camel.component.jpa.JpaConsumer.poll(JpaConsumer.java:75)

                          at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:139)

                          at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:91)

                          at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)

                          at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)

                          at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)

                          at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)

                          at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:180)

                          at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:204)

                          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)

                          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)

                          at java.lang.Thread.run(Thread.java:662)

                      Caused by: javax.persistence.TransactionRequiredException: no transaction is in progress

                          at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:970)

                          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

                          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                          at java.lang.reflect.Method.invoke(Method.java:597)

                          at org.springframework.orm.jpa.JpaTemplate$CloseSuppressingInvocationHandler.invoke(JpaTemplate.java:425)

                          at com.sun.proxy.$Proxy51.flush(Unknown Source)

                          at org.apache.camel.component.jpa.JpaConsumer$1.doInJpa(JpaConsumer.java:117)

                          at org.apache.camel.component.jpa.JpaTemplateTransactionStrategy$1$1.doInJpa(JpaTemplateTransactionStrategy.java:82)

                          at org.springframework.orm.jpa.JpaTemplate.execute(JpaTemplate.java:183)

                          ... 16 more

                       

                      any ideas?

                       

                      cheers

                       

                      Michael

                      • 8. Re: How to configure transaction manager with JPA Binding
                        Łukasz Dywicki Novice

                        I don't know details of your configuration, however there are few steps you have to ensure to avoid "no transaction is in progress" exceptions.

                         

                        • Deploy datasource in AS7
                        • Use jta-data-source in persistence.xml
                        • Make sure you set transaction manager property for binding

                         

                        From your stack trace looks like you have transaction manager set, however I don't see what kind of datasource you use. I asume the persistence unit 'org.jbpm.persistence.jpa2' is the bogus persistence unit which is intent to create transaction manager instance. If so please try use second workaround posted by me with custom transaction manager bean created by CDI.

                        • 9. Re: How to configure transaction manager with JPA Binding
                          michael melsen Newbie

                          Hi Łukasz

                           

                          thanks for your reply. Let me tell a bit more about my project and configuration. As stated before I'm combining the camel-mail and camel-jpa binding. I'm receiving an email, parsing it in a bean and invoking the jpa component that is using a persistenceunit to store the data using a db2 configured datasource in the db2 database. Here you see the dummy foo service as suggested by you earlier and the rest of the switchyard setup:

                           

                           

                           

                          Here you'll find the switchyard xml source:

                           

                          <?xml version="1.0" encoding="UTF-8"?>
                          <switchyard xmlns="urn:switchyard-config:switchyard:1.0" xmlns:bean="urn:switchyard-component-bean:config:1.0" xmlns:jpa="urn:switchyard-component-camel-jpa:config:1.0" xmlns:mail="urn:switchyard-component-camel-mail:config:1.0" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912" name="ZaaksysteemProcessHandler" targetNamespace="urn:nl.caci:ZaaksysteemProcessHandler:1.0">
                            <sca:composite name="ZaaksysteemProcessHandler" targetNamespace="urn:nl.caci:ZaaksysteemProcessHandler:1.0">
                              <sca:service name="ZaakSysteemEmail" promote="ZaakSysteemEmailBean/ZaakSysteemEmail">
                                <sca:interface.java interface="nl.caci.ZaaksysteemProcessHandler.ZaakSysteemEmail"/>
                                <mail:binding.mail secure="true">
                                  <mail:contextMapper/>
                                  <mail:host>imap.gmail.com</mail:host>
                                  <mail:username>username</mail:username>
                                  <mail:password>password</mail:password>
                                  <mail:consume accountType="imap">
                                    <mail:initialDelay>1000</mail:initialDelay>
                                    <mail:delay>12000</mail:delay>
                                    <mail:folderName>inbox</mail:folderName>
                                    <mail:disconnect>true</mail:disconnect>
                                  </mail:consume>
                                </mail:binding.mail>
                              </sca:service>
                              <sca:component name="ZaakSysteemEmailBean">
                                <bean:implementation.bean class="nl.caci.ZaaksysteemProcessHandler.ZaakSysteemEmailBean"/>
                                <sca:service name="ZaakSysteemEmail">
                                  <sca:interface.java interface="nl.caci.ZaaksysteemProcessHandler.ZaakSysteemEmail"/>
                                </sca:service>
                                <sca:reference name="StoreTodoReference">
                                  <sca:interface.java interface="nl.caci.ZaaksysteemProcessHandler.StoreTodo"/>
                                </sca:reference>
                              </sca:component>
                              <sca:reference name="StoreTodoReference" multiplicity="0..1" promote="ZaakSysteemEmailBean/StoreTodoReference">
                                <sca:interface.java interface="nl.caci.ZaaksysteemProcessHandler.StoreTodo"/>
                                <jpa:binding.jpa>
                                  <jpa:contextMapper/>
                                  <jpa:entityClassName>nl.caci.todo.TodoZGW</jpa:entityClassName>
                                  <jpa:persistenceUnit>JpaEvents</jpa:persistenceUnit>
                                  <jpa:transactionManager>#jtaTransactionManager</jpa:transactionManager>
                                  <jpa:consume>
                                    <jpa:initialDelay>1000</jpa:initialDelay>
                                    <jpa:delay>500</jpa:delay>
                                    <jpa:consumeDelete>true</jpa:consumeDelete>
                                    <jpa:consumeLockEntity>false</jpa:consumeLockEntity>
                                    <jpa:consumer.transacted>true</jpa:consumer.transacted>
                                  </jpa:consume>
                                </jpa:binding.jpa>
                              </sca:reference>
                              <sca:service name="Foo" promote="dummy/dummy">
                                <sca:interface.java interface="nl.caci.ZaaksysteemProcessHandler.ZaakSysteemEmail"/>
                                <jpa:binding.jpa>
                                  <jpa:contextMapper/>
                                  <jpa:entityClassName>nl.caci.todo.TodoZGW</jpa:entityClassName>
                                  <jpa:persistenceUnit>org.jbpm.persistence.jpa2</jpa:persistenceUnit>
                                  <jpa:transactionManager>#jtaTransactionManager</jpa:transactionManager>
                                </jpa:binding.jpa>
                              </sca:service>
                            </sca:composite>
                          </switchyard>
                          

                           

                           

                          I asume the persistence unit 'org.jbpm.persistence.jpa2' is the bogus persistence unit which is intent to create transaction manager instance.

                           

                          Yes, the jpa2 is the bogus persistence unit. Next you'll find the persistence.xml:

                           

                          <?xml version="1.0" encoding="UTF-8"?>
                          <persistence version="2.0"
                             xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                             xsi:schemaLocation="
                                  http://java.sun.com/xml/ns/persistence
                                  http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
                             <persistence-unit name="JpaEvents" transaction-type="JTA">
                          
                                <jta-data-source>java:jboss/datasources/vchDS</jta-data-source>
                                <class>nl.surf.domain.studielink.todo.TodoZGW</class>
                                <exclude-unlisted-classes>true</exclude-unlisted-classes>
                                <properties>
                                   <!-- Properties for Hibernate -->
                                   <!-- property name="hibernate.hbm2ddl.auto" value="create-drop" /  -->
                          
                                   <property name="hibernate.cache.use_second_level_cache" value="false"/>
                                   <property name="hibernate.show_sql" value="true" />
                          
                                   <property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform" />
                                </properties>
                             </persistence-unit>
                          
                              <persistence-unit name="org.jbpm.persistence.jpa2" transaction-type="JTA">
                                  <jta-data-source>java:jboss/datasources/vchDS</jta-data-source><!-- this is another JTA datasource which is enabled by default -->
                                  <!-- here is same or different config -->
                                <properties>
                                   <!-- Properties for Hibernate -->
                                   <!-- property name="hibernate.hbm2ddl.auto" value="create-drop" /-->
                          
                                   <property name="hibernate.cache.use_second_level_cache" value="false"/>
                                   <property name="hibernate.show_sql" value="true" />
                          
                                   <property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform" />
                                </properties>
                              </persistence-unit>   
                          </persistence>
                          

                           

                           

                          I'm using the test sources from the jpa quickstart and altered it to use a DB2Datasource to create a connection:

                           

                          import java.sql.Connection;
                          import java.sql.DriverManager;
                          import java.sql.SQLException;
                          
                          import javax.naming.InitialContext;
                          import javax.naming.Name;
                          import javax.naming.NamingException;
                          
                          import org.junit.AfterClass;
                          import org.junit.BeforeClass;
                          import org.switchyard.component.test.mixins.naming.NamingMixIn;
                          
                          import com.ibm.db2.jcc.DB2SimpleDataSource;
                          
                          public abstract class CamelJpaBindingTest {
                          
                              protected static final String RECEIVER = "Receiver";
                              protected static final String SENDER = "Sender";
                              protected static Connection connection;
                              private static NamingMixIn namingMixIn;
                          
                              @BeforeClass
                              public static void beforeClass() throws Exception {
                                  namingMixIn = new NamingMixIn();
                                  namingMixIn.initialize();
                          
                                  connection = DriverManager.getConnection("jdbc:db2://db_host:50002/mm", "vmo", "vmo");
                          
                                  DB2SimpleDataSource ds = new DB2SimpleDataSource();
                                  ds.setDatabaseName("mm");
                                  ds.setUser("vmo");
                                  ds.setPassword("vmo");
                                  ds.setPortNumber(50002);
                                  ds.setServerName("db_host");
                                  ds.setDriverType(4);
                                  ds.getConnection();
                                  InitialContext initialContext = new InitialContext();
                                  bind(initialContext, "java:jboss/datasources/vchDS", ds);
                          
                              }
                          
                              private static void bind(InitialContext initialContext, String name, Object object) throws NamingException {
                                  Name jndiName = initialContext.getNameParser("").parse(name);
                                  initialContext.bind(jndiName, object);
                              }
                          
                              @AfterClass
                              public static void shutDown() throws SQLException {
                                  if (!connection.isClosed()) {
                                      connection.close();
                                  }
                                  namingMixIn.uninitialize();
                              }
                          }
                          

                           

                           

                          and the store testclass:

                           

                          import static org.junit.Assert.assertEquals;
                          import static org.junit.Assert.assertTrue;
                          
                          import java.sql.PreparedStatement;
                          import java.sql.ResultSet;
                          
                          import nl.caci.todo.TodoZGW;
                          
                          import org.junit.Test;
                          import org.junit.runner.RunWith;
                          import org.switchyard.common.camel.SwitchYardCamelContext;
                          import org.switchyard.component.test.mixins.cdi.CDIMixIn;
                          import org.switchyard.component.test.mixins.transaction.TransactionMixIn;
                          import org.switchyard.test.SwitchYardRunner;
                          import org.switchyard.test.SwitchYardTestCaseConfig;
                          import org.switchyard.test.SwitchYardTestKit;
                          
                          @SwitchYardTestCaseConfig(
                              config = SwitchYardTestCaseConfig.SWITCHYARD_XML, 
                              mixins = {CDIMixIn.class,  TransactionMixIn.class}
                          )
                          @RunWith(SwitchYardRunner.class)
                          public class CamelJpaBindingStoreTest extends CamelJpaBindingTest {
                          
                              private SwitchYardTestKit _testKit;
                          
                              private SwitchYardCamelContext _context;
                          
                          
                              @Test
                              public void storeEntity() throws Exception {
                                  TodoZGW event = new TodoZGW();
                                  event.setDescription("test");
                                  event.setDossierId(1);
                                  event.setSlNumber(123456789);
                                  event.setZaakId(2);
                          
                                  _testKit.newInvoker("StoreTodoReference").sendInOnly(event);
                          
                          
                                 PreparedStatement statement = connection.prepareStatement("select * from TODO_ZGW");
                                  ResultSet resultSet = statement.executeQuery();
                          
                                  assertTrue(resultSet.next());
                                  assertEquals("test", resultSet.getString("DESCRIPTION"));
                              }
                          
                          }
                          

                           

                           

                           

                          If I use the CDI and try to run the unit test, I get this stacktrace stating that I have unsatisfied dependencies:

                           

                          org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [UserTransaction] with qualifiers [@Default] at injection point [[parameter 1] of [method] @Inject @Produces @Named public nl.caci.ZaaksysteemProcessHandler.TransactionManagerProducer.create(UserTransaction)]

                              at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:305)

                              at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:139)

                              at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:162)

                              at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:385)

                              at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:371)

                              at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:390)

                              at org.jboss.weld.environment.se.Weld.initialize(Weld.java:88)

                              at org.switchyard.component.test.mixins.cdi.CDIMixIn.initialize(CDIMixIn.java:87)

                              at org.switchyard.test.SwitchYardTestKit.initializeMixIns(SwitchYardTestKit.java:779)

                              at org.switchyard.test.SwitchYardTestKit.<init>(SwitchYardTestKit.java:170)

                              at org.switchyard.test.SwitchYardRunner.createTest(SwitchYardRunner.java:58)

                              at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:236)

                              at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)

                              at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:233)

                              at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)

                              at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)

                              at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)

                              at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)

                              at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)

                              at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)

                              at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)

                              at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)

                              at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)

                              at org.junit.runners.ParentRunner.run(ParentRunner.java:300)

                              at org.switchyard.test.SwitchYardRunner.run(SwitchYardRunner.java:90)

                              at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)

                              at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

                              at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)

                              at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)

                              at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)

                              at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

                           

                          I guess it is missing some dependency regarding javax.transaction.UserTransaction but the compiler doesn't complain about it, so this CDI doesn't work for me. for completeness I'll add my pom also:

                           

                          <?xml version="1.0" encoding="UTF-8"?>
                          <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
                              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                            <modelVersion>4.0.0</modelVersion>
                            <groupId>nl.caci</groupId>
                            <artifactId>ZaaksysteemProcessHandler</artifactId>
                            <version>0.0.1-SNAPSHOT</version>
                            <name>nl.caci:ZaaksysteemProcessHandler</name>
                            <properties>
                              <switchyard.version>1.0.0-SNAPSHOT</switchyard.version>
                            </properties>
                            <dependencies>
                              <dependency>
                                <groupId>org.switchyard.components</groupId>
                                <artifactId>switchyard-component-bean</artifactId>
                                <version>1.0.0-SNAPSHOT</version>
                                <scope>compile</scope>
                              </dependency>
                              <dependency>
                                <groupId>org.switchyard.components</groupId>
                                <artifactId>switchyard-component-camel</artifactId>
                                <version>1.0.0-SNAPSHOT</version>
                                <scope>compile</scope>
                              </dependency>
                              <dependency>
                                <groupId>org.switchyard.components</groupId>
                                <artifactId>switchyard-component-camel-jpa</artifactId>
                                <version>1.0.0-SNAPSHOT</version>
                                <scope>compile</scope>
                              </dependency>
                              <dependency>
                                <groupId>org.switchyard.components</groupId>
                                <artifactId>switchyard-component-camel-mail</artifactId>
                                <version>1.0.0-SNAPSHOT</version>
                                <scope>compile</scope>
                              </dependency>
                              <dependency>
                                <groupId>org.switchyard</groupId>
                                <artifactId>switchyard-api</artifactId>
                                <version>1.0.0-SNAPSHOT</version>
                                <scope>compile</scope>
                              </dependency>
                              <dependency>
                                <groupId>org.switchyard</groupId>
                                <artifactId>switchyard-transform</artifactId>
                                <version>1.0.0-SNAPSHOT</version>
                                <scope>compile</scope>
                              </dependency>
                              <dependency>
                                <groupId>org.switchyard</groupId>
                                <artifactId>switchyard-validate</artifactId>
                                <version>1.0.0-SNAPSHOT</version>
                                <scope>compile</scope>
                              </dependency>
                              <dependency>
                                <groupId>org.switchyard</groupId>
                                <artifactId>switchyard-plugin</artifactId>
                                <version>1.0.0-SNAPSHOT</version>
                                <scope>compile</scope>
                              </dependency>
                              <dependency>
                                <groupId>org.switchyard</groupId>
                                <artifactId>switchyard-test</artifactId>
                                <version>1.0.0-SNAPSHOT</version>
                                <scope>test</scope>
                              </dependency>
                              <dependency>
                                <groupId>org.hibernate</groupId>
                                <artifactId>hibernate-core</artifactId>
                                <version>4.0.1.Final</version>
                                <scope>compile</scope>
                              </dependency>
                              <dependency>
                                <groupId>org.hibernate</groupId>
                                <artifactId>hibernate-entitymanager</artifactId>
                                <version>4.0.1.Final</version>
                                <scope>compile</scope>
                              </dependency>
                              <dependency>
                                <groupId>com.ibm</groupId>
                                <artifactId>db2jcc4</artifactId>
                                <version>9.7.1</version>
                                <scope>provided</scope>
                              </dependency>
                              <dependency>
                                <groupId>org.switchyard.components</groupId>
                                <artifactId>switchyard-component-test-mixin-bpm</artifactId>
                                <version>1.0.0-SNAPSHOT</version>
                                <scope>test</scope>
                              </dependency>
                              <dependency>
                                <groupId>org.switchyard.components</groupId>
                                <artifactId>switchyard-component-test-mixin-hornetq</artifactId>
                                <version>1.0.0-SNAPSHOT</version>
                                <scope>test</scope>
                              </dependency>
                              <dependency>
                                <groupId>org.switchyard.components</groupId>
                                <artifactId>switchyard-component-test-mixin-http</artifactId>
                                <version>1.0.0-SNAPSHOT</version>
                                <scope>test</scope>
                              </dependency>
                              <dependency>
                                <groupId>org.switchyard.components</groupId>
                                <artifactId>switchyard-component-test-mixin-jca</artifactId>
                                <version>1.0.0-SNAPSHOT</version>
                                <scope>test</scope>
                              </dependency>
                              <dependency>
                                <groupId>org.switchyard.components</groupId>
                                <artifactId>switchyard-component-test-mixin-smooks</artifactId>
                                <version>1.0.0-SNAPSHOT</version>
                                <scope>test</scope>
                              </dependency>
                              <dependency>
                                <groupId>org.switchyard.components</groupId>
                                <artifactId>switchyard-component-test-mixin-cdi</artifactId>
                                <version>1.0.0-SNAPSHOT</version>
                                <scope>test</scope>
                              </dependency>
                              <dependency>
                                <groupId>org.switchyard.components</groupId>
                                <artifactId>switchyard-component-test-mixin-naming</artifactId>
                                <version>1.0.0-SNAPSHOT</version>
                                <scope>test</scope>
                              </dependency>
                            </dependencies>
                            <repositories>
                              <repository>
                                <releases>
                                  <enabled>true</enabled>
                                </releases>
                                <snapshots>
                                  <enabled>true</enabled>
                                </snapshots>
                                <id>central</id>
                                <url>http://central</url>
                              </repository>
                              <repository>
                                <releases>
                                  <enabled>true</enabled>
                                  <updatePolicy>never</updatePolicy>
                                  <checksumPolicy>fail</checksumPolicy>
                                </releases>
                                <snapshots>
                                  <enabled>true</enabled>
                                </snapshots>
                                <id>selenium-repo</id>
                                <name>Selenium Maven2 Repository</name>
                                <url>http://repo1.maven.org/maven2/org/seleniumhq/selenium/</url>
                              </repository>
                              <repository>
                                <id>jboss-public-repository</id>
                                <name>JBoss Public Maven Repository</name>
                                <url>http://repository.jboss.org/nexus/content/groups/public</url>
                              </repository>
                            </repositories>
                            <pluginRepositories>
                              <pluginRepository>
                                <id>jboss-public-repository</id>
                                <name>JBoss Public Maven Repository</name>
                                <url>http://repository.jboss.org/nexus/content/groups/public</url>
                              </pluginRepository>
                              <pluginRepository>
                                <releases>
                                  <enabled>true</enabled>
                                </releases>
                                <snapshots>
                                  <enabled>true</enabled>
                                </snapshots>
                                <id>central</id>
                                <url>http://central</url>
                              </pluginRepository>
                            </pluginRepositories>
                            <build>
                              <sourceDirectory>D:\Development\sources\ZGWPilot\ZaaksysteemProcessHandler\src\main\java</sourceDirectory>
                              <scriptSourceDirectory>D:\Development\sources\ZGWPilot\ZaaksysteemProcessHandler\src\main\scripts</scriptSourceDirectory>
                              <testSourceDirectory>D:\Development\sources\ZGWPilot\ZaaksysteemProcessHandler\src\test\java</testSourceDirectory>
                              <outputDirectory>D:\Development\sources\ZGWPilot\ZaaksysteemProcessHandler\target\classes</outputDirectory>
                              <testOutputDirectory>D:\Development\sources\ZGWPilot\ZaaksysteemProcessHandler\target\test-classes</testOutputDirectory>
                              <resources>
                                <resource>
                                  <directory>D:\Development\sources\ZGWPilot\ZaaksysteemProcessHandler\src\main\resources</directory>
                                </resource>
                              </resources>
                              <testResources>
                                <testResource>
                                  <directory>D:\Development\sources\ZGWPilot\ZaaksysteemProcessHandler\src\test\resources</directory>
                                </testResource>
                              </testResources>
                              <directory>D:\Development\sources\ZGWPilot\ZaaksysteemProcessHandler\target</directory>
                              <finalName>ZaaksysteemProcessHandler-0.0.1-SNAPSHOT</finalName>
                              <pluginManagement>
                                <plugins>
                                  <plugin>
                                    <artifactId>maven-antrun-plugin</artifactId>
                                    <version>1.3</version>
                                  </plugin>
                                  <plugin>
                                    <artifactId>maven-assembly-plugin</artifactId>
                                    <version>2.2-beta-5</version>
                                  </plugin>
                                  <plugin>
                                    <artifactId>maven-dependency-plugin</artifactId>
                                    <version>2.1</version>
                                  </plugin>
                                  <plugin>
                                    <artifactId>maven-release-plugin</artifactId>
                                    <version>2.0</version>
                                  </plugin>
                                </plugins>
                              </pluginManagement>
                              <plugins>
                                <plugin>
                                  <groupId>org.switchyard</groupId>
                                  <artifactId>switchyard-plugin</artifactId>
                                  <version>1.0.0-SNAPSHOT</version>
                                  <executions>
                                    <execution>
                                      <goals>
                                        <goal>configure</goal>
                                      </goals>
                                      <configuration>
                                        <scannerClassNames>
                                          <param>org.switchyard.transform.config.model.TransformSwitchYardScanner</param>
                                        </scannerClassNames>
                                      </configuration>
                                    </execution>
                                  </executions>
                                  <configuration>
                                    <scannerClassNames>
                                      <param>org.switchyard.transform.config.model.TransformSwitchYardScanner</param>
                                    </scannerClassNames>
                                  </configuration>
                                </plugin>
                                <plugin>
                                  <artifactId>maven-compiler-plugin</artifactId>
                                  <version>2.3.2</version>
                                  <executions>
                                    <execution>
                                      <id>default-testCompile</id>
                                      <phase>test-compile</phase>
                                      <goals>
                                        <goal>testCompile</goal>
                                      </goals>
                                      <configuration>
                                        <source>1.6</source>
                                        <target>1.6</target>
                                        <debug>true</debug>
                                        <showWarnings>true</showWarnings>
                                        <showDeprecation>true</showDeprecation>
                                      </configuration>
                                    </execution>
                                    <execution>
                                      <id>default-compile</id>
                                      <phase>compile</phase>
                                      <goals>
                                        <goal>compile</goal>
                                      </goals>
                                      <configuration>
                                        <source>1.6</source>
                                        <target>1.6</target>
                                        <debug>true</debug>
                                        <showWarnings>true</showWarnings>
                                        <showDeprecation>true</showDeprecation>
                                      </configuration>
                                    </execution>
                                  </executions>
                                  <configuration>
                                    <source>1.6</source>
                                    <target>1.6</target>
                                    <debug>true</debug>
                                    <showWarnings>true</showWarnings>
                                    <showDeprecation>true</showDeprecation>
                                  </configuration>
                                </plugin>
                                <plugin>
                                  <artifactId>maven-clean-plugin</artifactId>
                                  <version>2.4.1</version>
                                  <executions>
                                    <execution>
                                      <id>default-clean</id>
                                      <phase>clean</phase>
                                      <goals>
                                        <goal>clean</goal>
                                      </goals>
                                    </execution>
                                  </executions>
                                </plugin>
                                <plugin>
                                  <artifactId>maven-install-plugin</artifactId>
                                  <version>2.3.1</version>
                                  <executions>
                                    <execution>
                                      <id>default-install</id>
                                      <phase>install</phase>
                                      <goals>
                                        <goal>install</goal>
                                      </goals>
                                    </execution>
                                  </executions>
                                </plugin>
                                <plugin>
                                  <artifactId>maven-resources-plugin</artifactId>
                                  <version>2.5</version>
                                  <executions>
                                    <execution>
                                      <id>default-resources</id>
                                      <phase>process-resources</phase>
                                      <goals>
                                        <goal>resources</goal>
                                      </goals>
                                    </execution>
                                    <execution>
                                      <id>default-testResources</id>
                                      <phase>process-test-resources</phase>
                                      <goals>
                                        <goal>testResources</goal>
                                      </goals>
                                    </execution>
                                  </executions>
                                </plugin>
                                <plugin>
                                  <artifactId>maven-surefire-plugin</artifactId>
                                  <version>2.10</version>
                                  <executions>
                                    <execution>
                                      <id>default-test</id>
                                      <phase>test</phase>
                                      <goals>
                                        <goal>test</goal>
                                      </goals>
                                    </execution>
                                  </executions>
                                </plugin>
                                <plugin>
                                  <artifactId>maven-jar-plugin</artifactId>
                                  <version>2.3.2</version>
                                  <executions>
                                    <execution>
                                      <id>default-jar</id>
                                      <phase>package</phase>
                                      <goals>
                                        <goal>jar</goal>
                                      </goals>
                                    </execution>
                                  </executions>
                                </plugin>
                                <plugin>
                                  <artifactId>maven-deploy-plugin</artifactId>
                                  <version>2.7</version>
                                  <executions>
                                    <execution>
                                      <id>default-deploy</id>
                                      <phase>deploy</phase>
                                      <goals>
                                        <goal>deploy</goal>
                                      </goals>
                                    </execution>
                                  </executions>
                                </plugin>
                                <plugin>
                                  <artifactId>maven-site-plugin</artifactId>
                                  <version>3.0</version>
                                  <executions>
                                    <execution>
                                      <id>default-site</id>
                                      <phase>site</phase>
                                      <goals>
                                        <goal>site</goal>
                                      </goals>
                                      <configuration>
                                        <outputDirectory>D:\Development\sources\ZGWPilot\ZaaksysteemProcessHandler\target\site</outputDirectory>
                                        <reportPlugins>
                                          <reportPlugin>
                                            <groupId>org.apache.maven.plugins</groupId>
                                            <artifactId>maven-project-info-reports-plugin</artifactId>
                                          </reportPlugin>
                                        </reportPlugins>
                                      </configuration>
                                    </execution>
                                    <execution>
                                      <id>default-deploy</id>
                                      <phase>site-deploy</phase>
                                      <goals>
                                        <goal>deploy</goal>
                                      </goals>
                                      <configuration>
                                        <outputDirectory>D:\Development\sources\ZGWPilot\ZaaksysteemProcessHandler\target\site</outputDirectory>
                                        <reportPlugins>
                                          <reportPlugin>
                                            <groupId>org.apache.maven.plugins</groupId>
                                            <artifactId>maven-project-info-reports-plugin</artifactId>
                                          </reportPlugin>
                                        </reportPlugins>
                                      </configuration>
                                    </execution>
                                  </executions>
                                  <configuration>
                                    <outputDirectory>D:\Development\sources\ZGWPilot\ZaaksysteemProcessHandler\target\site</outputDirectory>
                                    <reportPlugins>
                                      <reportPlugin>
                                        <groupId>org.apache.maven.plugins</groupId>
                                        <artifactId>maven-project-info-reports-plugin</artifactId>
                                      </reportPlugin>
                                    </reportPlugins>
                                  </configuration>
                                </plugin>
                              </plugins>
                            </build>
                            <reporting>
                              <outputDirectory>D:\Development\sources\ZGWPilot\ZaaksysteemProcessHandler\target\site</outputDirectory>
                            </reporting>
                          </project>
                          

                           

                           

                          Hope you can help me getting this thing to work, thanks anyway!

                           

                          cheers

                           

                          Michael

                          • 10. Re: How to configure transaction manager with JPA Binding
                            Łukasz Dywicki Novice

                            Hey Michael,

                            Thank you for posting your configuration. Let me suggest some changes:

                             

                            • Use one from two - dummy consumer or CDI bean producer
                            • Use different datasource for dummy consumer (eg. ExampleDS)
                            • The sca:reference doesn't support jpa:consume element, it have impact only for service bindings

                             

                            Since you have StoreTodoReference it produces rows in database for entities. The Foo service consume database rows and create entities from them. These terms come from JMS/Camel - in service bindings you have always consumer, in reference bindings you have always producers.

                             

                            The problem you reported is caused by fact that you produce entity and then another reference tries to read it. If you will use two different databases you will avoid this problem since table in second database will be empty all the time.

                            • 11. Re: How to configure transaction manager with JPA Binding
                              michael melsen Newbie

                              Hi Łukasz,

                               

                              I would rather use the cdi bean producer so I can keep the switchyard.xml file from any workaround configs like the foo service. So I have this switchyard.xml and have removed the jpa:consume, the foo service and the dummy datasource:

                               

                              <?xml version="1.0" encoding="UTF-8"?>

                              <switchyard xmlns="urn:switchyard-config:switchyard:1.0" xmlns:bean="urn:switchyard-component-bean:config:1.0" xmlns:jpa="urn:switchyard-component-camel-jpa:config:1.0" xmlns:mail="urn:switchyard-component-camel-mail:config:1.0" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912" name="ZaaksysteemProcessHandler" targetNamespace="urn:nl.caci:ZaaksysteemProcessHandler:1.0">

                                <sca:composite name="ZaaksysteemProcessHandler" targetNamespace="urn:nl.caci:ZaaksysteemProcessHandler:1.0">

                                  <sca:service name="ZaakSysteemEmail" promote="ZaakSysteemEmailBean/ZaakSysteemEmail">

                                    <sca:interface.java interface="nl.caci.ZaaksysteemProcessHandler.ZaakSysteemEmail"/>

                                    <mail:binding.mail secure="true">

                                      <mail:contextMapper/>

                                      <mail:host>imap.gmail.com</mail:host>

                                      <mail:username>username</mail:username>

                                      <mail:password>password</mail:password>

                                      <mail:consume accountType="imap">

                                        <mail:initialDelay>1000</mail:initialDelay>

                                        <mail:delay>12000</mail:delay>

                                        <mail:folderName>inbox</mail:folderName>

                                        <mail:disconnect>true</mail:disconnect>

                                      </mail:consume>

                                    </mail:binding.mail>

                                  </sca:service>

                                  <sca:component name="ZaakSysteemEmailBean">

                                    <bean:implementation.bean class="nl.caci.ZaaksysteemProcessHandler.ZaakSysteemEmailBean"/>

                                    <sca:service name="ZaakSysteemEmail">

                                      <sca:interface.java interface="nl.caci.ZaaksysteemProcessHandler.ZaakSysteemEmail"/>

                                    </sca:service>

                                    <sca:reference name="StoreTodoReference">

                                      <sca:interface.java interface="nl.caci.ZaaksysteemProcessHandler.StoreTodo"/>

                                    </sca:reference>

                                  </sca:component>

                                  <sca:reference name="StoreTodoReference" multiplicity="0..1" promote="ZaakSysteemEmailBean/StoreTodoReference">

                                    <sca:interface.java interface="nl.caci.ZaaksysteemProcessHandler.StoreTodo"/>

                                    <jpa:binding.jpa>

                                      <jpa:contextMapper/>

                                      <jpa:entityClassName>nl.caci.TodoZGW</jpa:entityClassName>

                                      <jpa:persistenceUnit>JpaEvents</jpa:persistenceUnit>

                                      <jpa:transactionManager>#springPlatformTransactionManager</jpa:transactionManager>

                                    </jpa:binding.jpa>

                                  </sca:reference>

                                </sca:composite>

                              </switchyard>

                               

                              and the producer:

                               

                              package nl.caci.ZaaksysteemProcessHandler;

                               

                              import javax.enterprise.inject.Produces;

                              import javax.inject.Named;

                              import javax.transaction.UserTransaction;

                               

                              import org.springframework.transaction.PlatformTransactionManager;

                              import org.springframework.transaction.jta.JtaTransactionManager;

                               

                              import com.google.inject.Inject;

                               

                              public class TransactionManagerProducer {

                                  @Inject @Produces @Named("springPlatformTransactionManager")

                                  public PlatformTransactionManager create(UserTransaction ut) {

                                      return new JtaTransactionManager(ut);

                                  }

                              }

                               

                              and a simple persistenceunit without the dummy datasource:

                               

                              <?xml version="1.0" encoding="UTF-8"?>

                              <persistence version="2.0"

                                 xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                                 xsi:schemaLocation="

                                      http://java.sun.com/xml/ns/persistence

                                      http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">

                                 <persistence-unit name="JpaEvents">

                               

                                    <jta-data-source>java:jboss/datasources/vchDS</jta-data-source>

                                    <class>nl.surf.domain.studielink.todo.TodoZGW</class>

                                    <exclude-unlisted-classes>true</exclude-unlisted-classes>

                                    <properties>

                                       <!-- Properties for Hibernate -->

                                       <!-- property name="hibernate.hbm2ddl.auto" value="create-drop" /  -->

                               

                                       <property name="hibernate.cache.use_second_level_cache" value="false"/>

                                       <property name="hibernate.show_sql" value="true" />

                               

                                       <property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform" />

                                    </properties>

                                 </persistence-unit>

                              </persistence>

                               

                              The problem with the unsatisfied dependencies still remains...

                               

                              Hope you can give one more hint

                               

                              regards,

                               

                              michael

                              • 12. Re: How to configure transaction manager with JPA Binding
                                Łukasz Dywicki Novice

                                Please skip test and try deploy it on SwitchYard - it should work. We have solved SWITCHYARD-1114 in 0.7 release, maybe there is some regression. Will check that next week.

                                • 13. Re: How to configure transaction manager with JPA Binding
                                  michael melsen Newbie

                                  Hi,

                                   

                                  it really works like a charm now! just deployed it and I see my mail getting parsed and added to the database through jpa

                                   

                                  thanks a lot for your help

                                   

                                  cheers!

                                  • 14. Re: How to configure transaction manager with JPA Binding
                                    Keith Babo Master

                                    Lukasz - can you create a JIRA to track the issue reported in this thread? 

                                     

                                    thanks,

                                    keith

                                    1 2 Previous Next