1 2 Previous Next 21 Replies Latest reply on Apr 11, 2013 2:21 PM by Put Time

    Implementing "quickstart\jca-inflow-hornetq" sample.

    Put Time Newbie

      I'm trying to implement a "jca-inflow-hornetq" quickstart example from scratch.

       

      Here's the list of steps so far:

      1. Create a new "SwitchYard project".

      2. Select "Bean", "JMS" and "HornetQ Mixin" components.

       

      Now we see the switchyard GUI.

      3. Now drag and drop "Bean" component.

      4. I'll call the interface as "HornetQTestService" and the bean as "HornetQTestServiceBean"

       

      5. In the "HornetQTestService" interface, I'll add two methods called

                                    void english(Person person);

                                    void spanish(Person person);

      6. I'll then create the class "Person" and it's contents are like this:

       

      @XmlRootElement

      public class Person {

          String     _name;

          String    _language;

         

          public String getName() {

              return _name;

          }

          public void setName(String name) {

              this._name = name;

          }

          public String getLanguage() {

              return _language;

          }

          public void setLanguage(String language) {

              this._language = language;

          }

      }

       

       

       

      7. Now I try and do something with this, and it doesn't work. For example, if I right-click in the GUI on the bean component, neither the "Promote service" nor the "Generate test" option shows up.

       

       

      I'm not able to go beyond this point. Can anyone help me out?

        • 1. Re: Implementing "quickstart\jca-inflow-hornetq" sample.
          Keith Babo Master

          To do either of those things, you need to right-click on the green service icon and not the component.  If you are using tooling from 0.8.0.Final then you can hover over the green service icon and use the resulting "button bar" menu to promote and generate test.

          1 of 1 people found this helpful
          • 2. Re: Implementing "quickstart\jca-inflow-hornetq" sample.
            Put Time Newbie

            [Thanks that worked]

             

            7. I right-click on the "green" component and do a "promote service".

            8. I use the "WSDL" option.

            9. Then I drag & drop the "JMS" component to the promoted service.

                     I give the queue name as "MyQueue1"

             

             

            I deploy this on the server. Now I want to test this setup.

             

            I used the "HornetQClient.java" file that is supplied with the quickstart sample.

             

            But I get a "unresolved error" for the following 3 lines:

             

            import javax.jms.MessageProducer;

            import javax.jms.Session;

            import javax.jms.TextMessage;

             

            Are there libraries that I need to add specifically?

            How do I fix that error?

            • 3. Re: Implementing "quickstart\jca-inflow-hornetq" sample.
              Keith Babo Master

              You need this dependency in your application's pom.xml for the test client:

               

                     

                      <dependency>
                          <groupId>javax.jms</groupId>
                          <artifactId>jms</artifactId>
                           <version>1.1</version>
                          <scope>test</scope>
                      </dependency>
              
              • 4. Re: Implementing "quickstart\jca-inflow-hornetq" sample.
                Keith Babo Master

                Actually, if you are running the class as a standalone java application from the IDE and not a unit test, then I would remove the <scope>test</scope>, so

                 

                         <dependency>
                            <groupId>javax.jms</groupId>
                            <artifactId>jms</artifactId>
                             <version>1.1</version>
                        </dependency>

                1 of 1 people found this helpful
                • 5. Re: Implementing "quickstart\jca-inflow-hornetq" sample.
                  Put Time Newbie

                  Ok, thanks again, That worked. Now on to other details::

                   

                  [BTW, after I'm done with this, I'll probably publish this exercise as a video or blog article. That way it'll help others.]

                   

                   

                  Now I get this error. How do I get around this?

                   

                  javax.jms.InvalidDestinationException: Destination MyQueue1 does not exist

                      at org.hornetq.jms.client.HornetQSession.createProducer(HornetQSession.java:337)

                      at com.example.switchyard.episode9_hornetq_test1.HornetQClientTest.main(HornetQClientTest.java:68)

                      at com.example.switchyard.episode9_hornetq_test1.HornetQClientTest.defaultExecute(HornetQClientTest.java:91)

                      at com.example.switchyard.episode9_hornetq_test1.HornetQClientTest.main(HornetQClientTest.java:60)

                   

                   

                  One difference that I see is that the XML file "switchyard-quickstart-jca-inflow-hornetq-jms.xml" which is in the folder <quickstarts\jca-inflow-hornetq\src\test\resources>.

                  This is the file that needs to be copied to the "deployments" folder.

                   

                  I don't see a similar one in my project. How do I generate this file? Or do I just create it by hand and use it?

                  • 6. Re: Implementing "quickstart\jca-inflow-hornetq" sample.
                    Keith Babo Master

                    That's the queue definition which you can create by hand (you should also be able to create via AS admin interfaces).  I would just take the example in jca-inflow-hornetq-jms.xml and change both instances of JCAInflowGreetingServiceQueue to be MyQueue1.  Then deploy that file by copying it into your standalone/deployments directory.

                    • 7. Re: Implementing "quickstart\jca-inflow-hornetq" sample.
                      Put Time Newbie

                      I created the XML and also copied it to deployments folder, and the above mentioned error was fixed. Thanks for that.

                      [The error that I'm getting now is mentioned at the end of this post]

                       

                      Just reiterating the steps:

                       

                      Here's the list of steps so far:

                      1. Create a new "SwitchYard project".

                      2. Select "Bean", "JMS" and "HornetQ Mixin" components.

                       

                      Now we see the switchyard GUI.

                      3. Now drag and drop "Bean" component.

                      4. I'll call the interface as "HornetQTestService" and the bean as "HornetQTestServiceBean"

                       

                      5. In the "HornetQTestService" interface, I'll add two methods called

                                                    void english(Person person);

                                                    void spanish(Person person);

                      6. I'll then create the class "Person" and it's contents are like this:

                       

                      @XmlRootElement

                      public class Person {

                          String     _name;

                          String    _language;

                         

                          public String getName() {

                              return _name;

                          }

                          public void setName(String name) {

                              this._name = name;

                          }

                          public String getLanguage() {

                              return _language;

                          }

                          public void setLanguage(String language) {

                              this._language = language;

                          }

                      }

                       

                       

                      7. I right-click on the "green" component and do a "promote service".

                      8. I use the "WSDL" option.

                      9. The I go into "Create Transformers" and select JAXB.

                      9. Then I drag & drop the "JMS" component to the promoted service.

                               I give the queue name as "MyQueue1"

                      10. I then create a XML like this and copy it to "deployments" folder.

                       

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

                      <messaging-deployment xmlns="urn:jboss:messaging-deployment:1.0">

                          <hornetq-server>

                              <jms-destinations>

                                  <jms-queue name="MyQueue1">

                                      <entry name="MyQueue1"/>

                                  </jms-queue>

                              </jms-destinations>

                          </hornetq-server>

                      </messaging-deployment>

                       

                       

                      11. I create a standalone test class to test this. So in pom.xml, I add the following block:

                       

                      <dependency>
                                  <groupId>javax.jms</groupId>
                                  <artifactId>jms</artifactId>
                                   <version>1.1</version>
                                  <scope>test</scope>
                              </dependency>

                       

                      12. My switchyard.xml looks like this:

                       

                       

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

                        <sca:composite name="episode9-hornetq-test1" targetNamespace="urn:com.example.switchyard:episode9-hornetq-test1:1.0">

                          <sca:component name="HornetQTestServiceBean">

                            <bean:implementation.bean class="com.example.switchyard.episode9_hornetq_test1.HornetQTestServiceBean"/>

                            <sca:service name="HornetQTestService">

                              <sca:interface.java interface="com.example.switchyard.episode9_hornetq_test1.HornetQTestService"/>

                            </sca:service>

                          </sca:component>

                          <sca:service name="HornetQTestServicePortType" promote="HornetQTestServiceBean/HornetQTestService">

                            <sca:interface.wsdl interface="HornetQTestService.wsdl#wsdl.porttype(HornetQTestServicePortType)"/>

                            <jms:binding.jms>

                              <operationSelector.xpath expression="//person/language"/>

                              <jms:queue>MyQueue1</jms:queue>

                              <jms:connectionFactory>#ConnectionFactory</jms:connectionFactory>

                            </jms:binding.jms>

                          </sca:service>

                        </sca:composite>

                        <transforms>

                          <transform:transform.jaxb from="{urn:com.example.switchyard:episode9-hornetq-test1:1.0}english" to="java:com.example.switchyard.episode9_hornetq_test1.Person"/>

                          <transform:transform.jaxb from="{urn:com.example.switchyard:episode9-hornetq-test1:1.0}spanish" to="java:com.example.switchyard.episode9_hornetq_test1.Person"/>

                        </transforms>

                      </switchyard>

                       

                       

                      --------------------------------------

                       

                      Now when I run the test app, I get this error on the server:

                       

                      Exception occurred during execution on the exchange: Exchange[JmsMessage[JmsMessageID: ID:01bc4de9-a1fa-11e2-a487-7d92151f35e9]]: org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[JmsMessage[JmsMessageID: ID:01bc4de9-a1fa-11e2-a487-7d92151f35e9]]

                          at org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1296) [camel-core-2.10.0.jar:2.10.0]

                          at org.apache.camel.impl.DefaultExchange.setException(DefaultExchange.java:282) [camel-core-2.10.0.jar:2.10.0]

                          at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:64) [camel-core-2.10.0.jar:2.10.0]

                       

                      Caused by: java.lang.NoClassDefFoundError: org/slf4j/Logger

                          at org.switchyard.component.camel.SwitchYardProducer.getOperationName(SwitchYardProducer.java:130) [switchyard-component-camel-switchyard-0.8.0.Final.jar:0.8.0.Final]

                          at org.switchyard.component.camel.SwitchYardProducer.lookupOperationNameFor(SwitchYardProducer.java:167) [switchyard-component-camel-switchyard-0.8.0.Final.jar:0.8.0.Final]

                          at org.switchyard.component.camel.SwitchYardProducer.createSwitchyardExchange(SwitchYardProducer.java:152) [switchyard-component-camel-switchyard-0.8.0.Final.jar:0.8.0.Final]

                          at org.switchyard.component.camel.SwitchYardProducer.process(SwitchYardProducer.java:89) [switchyard-component-camel-switchyard-0.8.0.Final.jar:0.8.0.Final]

                          at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61) [camel-core-2.10.0.jar:2.10.0]

                       

                       

                      how can I fix this error?

                      • 8. Re: Implementing "quickstart\jca-inflow-hornetq" sample.
                        Keith Babo Master

                        Not sure on why you are hitting that in getOperationName().  Can you zip up your project and send it?  Are you able to deploy and test the jca-inflow-quickstart on the same installation following the instructions in the Readme?  If you get the same error with that quickstart, I suspect there's somethign funky in your SY runtime and would recommend a clean install of the server.  If you don't see the issue with the quickstart, then I would have to check out your app to say more.

                        • 9. Re: Implementing "quickstart\jca-inflow-hornetq" sample.
                          Put Time Newbie

                          The quickstart "jca-inflow" app works fine now.

                           

                          I'm having problems with my app, because I tried to build it from scratch.

                           

                          Attached is the zipped up project.

                           

                          Thanks

                          • 10. Re: Implementing "quickstart\jca-inflow-hornetq" sample.
                            Keith Babo Master

                            Just tried your app against a clean 0.8.0.Final runtime and it worked fine.  I built your app, copied it into the deployments directory along with the queue definition, then ran mvn exec:java.  Here's what I see:

                             

                            <?xml version="1.0" encoding="UTF-8"?>
                            <qs:person xmlns:qs="urn:com.example.switchyard:episode9-hornetq-test1:1.0">
                                <name>Trippy</name>
                                <language>english</language>
                            </qs:person>
                            
                            
                            Sent message [HornetQMessage[ID:05ed54c5-a24c-11e2-9752-20c9d0433ba5]:PERSISTENT]
                            

                             

                            I recommend nuking your SY runtime install or creating another fresh install and trying it again.

                             

                            • 11. Re: Implementing "quickstart\jca-inflow-hornetq" sample.
                              Put Time Newbie

                              The test app (client) works, the problem is on the server side. If you see the server logs, you can see the exception there.

                               

                              Thanks

                              • 12. Re: Implementing "quickstart\jca-inflow-hornetq" sample.
                                Keith Babo Master

                                I did check the server log when running the deployment and it was clean.  Looking again at the app you attached, there's no composite service or binding in it, which would explain why I'm not seeing an error.   You have a binding definition in the switchyard.xml snippet you pasted earlier, so maybe you attached the wrong version of the app?

                                 

                                I did notice that this thread's title that you are trying to recreate the jca-inflow-hornetq quickstart and yet the binding you are using is binding.jms instead of binding.jca.  It's possible that there is a module dependency missing for our JMS gateway on slf4j.  That would explain why the JCA quickstart works for you and your recreated app doesn't.

                                • 13. Re: Implementing "quickstart\jca-inflow-hornetq" sample.
                                  Put Time Newbie

                                  So sorry about that. I was experimenting a lot, trying to get to the root of the problem, and had totally messed up the project.

                                   

                                  So I thought I'd start from scratch again. But this time i'm running into a stranger problem.

                                   

                                  1. I create the project.

                                  2. I create the bean service and the interface.

                                   

                                  Now when I try to promote the service, through a WSDL interface, I get this error saying: "local part cannot be "null".

                                  Please see attached screenshot.

                                   

                                  How do I get around this?

                                   

                                   

                                   

                                  • 14. Re: Implementing "quickstart\jca-inflow-hornetq" sample.
                                    Keith Babo Master

                                    Did you add operations to the Java interface?

                                    1 2 Previous Next