3 Replies Latest reply on May 17, 2013 10:55 AM by Keith Babo

    Regarding switchyard-quickstart-camel-jpa-binding

    simon shen Newbie

      I just create a new switchyard project and want to implement a sample like switchyard-quickstart-camel-jpa-binding.

      Here's my switchyard design and source.

      sy.PNG

      <?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:quartz="urn:switchyard-component-camel-quartz:config:1.0" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912" name="episode10" targetNamespace="urn:com.example.switchyard:episode10:1.0">

        <sca:composite name="episode10" targetNamespace="urn:com.example.switchyard:episode10:1.0">

          <sca:component name="PeriodicServiceBean">

            <bean:implementation.bean class="com.example.switchyard.episode10.PeriodicServiceBean"/>

            <sca:service name="PeriodicService">

              <sca:interface.java interface="com.example.switchyard.episode10.PeriodicService"/>

            </sca:service>

            <sca:reference name="StoreService">

              <sca:interface.java interface="com.example.switchyard.episode10.StoreService"/>

            </sca:reference>

          </sca:component>

          <sca:service name="PeriodicService" promote="PeriodicServiceBean/PeriodicService">

            <sca:interface.java interface="com.example.switchyard.episode10.StoreService"/>

            <quartz:binding.quartz>

              <quartz:contextMapper/>

              <quartz:name>episode10</quartz:name>

              <quartz:cron>*/5 * * * * ?</quartz:cron>

            </quartz:binding.quartz>

          </sca:service>

          <sca:reference name="StoreReference" multiplicity="0..1" promote="PeriodicServiceBean/StoreService">

            <sca:interface.java interface="com.example.switchyard.episode10.StoreService"/>

            <jpa:binding.jpa>

              <jpa:contextMapper/>

              <jpa:entityClassName>com.example.switchyard.episode10.Greet</jpa:entityClassName>

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

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

              <jpa:produce/>

            </jpa:binding.jpa>

          </sca:reference>

        </sca:composite>

      </switchyard>

       

      Of course, I have persistent.xml and other source files like following:

      pp.PNG

      After deployed successfully, I got such exception:

      17:30:55,024 INFO  [com.example.switchyard.episode10.PeriodicServiceBean] (DefaultQuartzScheduler-camel-3_Worker-4) Sending Greet [null, from David, to Rob, created on Fri May 17 17:30:55 CST 2013] to JPA _store

      17:30:55,034 WARN  [org.switchyard.component.bean.ServiceProxyHandler] (DefaultQuartzScheduler-camel-3_Worker-4) Invocation of operation 'execute' on bean component 'com.example.switchyard.episode10.PeriodicServiceBeanfailed.: java.lang.reflect.InvocationTargetException

              at sun.reflect.GeneratedMethodAccessor24.invoke(Unknown Source) [:1.7.0]

              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0]

      ......

      Caused by: org.switchyard.component.bean.BeanComponentException: A service reference to service 'StoreReference' is not bound into this client proxy instance.  A reference configuration to the service may be required in the application configuration.

      ......

       

      @Service(PeriodicService.class)

      public class PeriodicServiceBean implements PeriodicService {

       

          @Inject

          @Reference("StoreReference")

          private StoreService _store;

       

          public void execute() {

              Greet greet = createRandomGreet();

              _logger.info("Sending {} to JPA _store", greet);

              _store.storeGreeting(greet);

          }

      ......

      }

       

      Since in the log, we can see "Sending Greet..." has been printed, but failed to execute "_store.storeGreeting" caused by injection failed I think.

      But I don't know how to fix this issue.

      I'd appreciate who can help me.

      Thanks.

        • 1. Re: Regarding switchyard-quickstart-camel-jpa-binding
          Keith Babo Master
          @Reference("StoreReference")
          

           

          should be

           

          @Reference("StoreService")
          
          1 of 1 people found this helpful
          • 2. Re: Regarding switchyard-quickstart-camel-jpa-binding
            simon shen Newbie

            Thanks for your response.

            Another issue after fixed the above one,

             

            22:50:05,055 WARN  [org.switchyard.internal.ExchangeImpl] (DefaultQuartzScheduler-camel-1_Worker-1) Fault generated during exchange without a handler: org.switchyard.HandlerException: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: jpa://com.example.switchyard.episode10.Greet?persistenceUnit=JpaEvents&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://com.example.switchyard.episode10.Greet?persistenceUnit=JpaEvents&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

            • 3. Re: Regarding switchyard-quickstart-camel-jpa-binding
              Keith Babo Master

              Assuming you are using 0.8.0.Final, you're hitting this (which is fixed in 1.0.0-SNAPSHOT):

               

              https://issues.jboss.org/browse/SWITCHYARD-1387