1 2 Previous Next 16 Replies Latest reply on Nov 30, 2012 2:39 AM by carl918

    Use of ServiceInvoker to test an ESB service

    bfitzpat

      Hi all...

       

      I'm trying to customize some test code to test the aggregator sample via a SendEsbMessage java class, similar to how it's been used for other ESB runtime examples, and am not having much luck.

       

      To give some context, I'm trying to make some of the examples that aren't currently usable in JBoss Tools into importable examples that folks can import, build, deploy, and test within the tooling.

       

      Here's what I have so far:

       

      {code}

      public class SendEsbMessage

      {

          public static void main(String args[]) throws Exception

          {

      //      Setting the ConnectionFactory such that it will use scout

              System.setProperty("javax.xml.registry.ConnectionFactoryClass","org.apache.ws.scout.registry.ConnectionFactoryImpl");

             

              Message esbMessage = MessageFactory.getInstance().getMessage();

       

              if (args.length < 3)

              {

                  String fileContent = readFile ("SampleOrder.xml");

                  System.out.println("---------------------------------------------");

                  System.out.println(fileContent);

                  System.out.println("---------------------------------------------");

                  System.out.println("Usage SendEsbMessage <category> <name> <text to send>");

                  args = new String[]{"Aggregation", "OrderAggregrator", fileContent};

              }

             

              esbMessage.getBody().add(args[2]);

              new ServiceInvoker(args[0], args[1]).deliverAsync(esbMessage);

             

          }

         

          private static String readFile( String file ) throws IOException {

              BufferedReader reader = new BufferedReader( new FileReader (file));

              String line  = null;

              StringBuilder stringBuilder = new StringBuilder();

              String ls = System.getProperty("line.separator");

              while( ( line = reader.readLine() ) != null ) {

                  stringBuilder.append( line );

                  stringBuilder.append( ls );

              }

              return stringBuilder.toString();

           }

         

      }

      {code}

       

      Am I doing something obviously wrong? There's a queue associated with the OrderAggregator service, and it appears that's what I need to put the sample on...

       

      Thanks in advance!

      --Fitz

        • 1. Re: Use of ServiceInvoker to test an ESB service
          mageshbk

          Hi Brian,

           

          You will need to send the Message to the SplitterService

           

          args = new String[]{"MessageRouting", "SplitterService", fileContent};

          • 2. Re: Use of ServiceInvoker to test an ESB service
            bfitzpat

            Thanks Magesh, but for some reason running that as a Java program in Eclipse throws an exception. Any ideas?

             

            {code}

            Usage SendEsbMessage <category> <name> <text to send>

            Exception in thread "main" org.jboss.soa.esb.listeners.message.MessageDeliverException: Invocation exception. null

                at org.jboss.soa.esb.client.ServiceInvoker.loadServiceClusterInfo(ServiceInvoker.java:545)

                at org.jboss.soa.esb.client.ServiceInvoker.<init>(ServiceInvoker.java:174)

                at org.jboss.soa.esb.client.ServiceInvoker.<init>(ServiceInvoker.java:155)

                at org.jboss.soa.esb.client.ServiceInvoker.<init>(ServiceInvoker.java:197)

                at org.jboss.soa.esb.samples.quickstart.aggregator.test.SendEsbMessage.main(SendEsbMessage.java:70)

            Caused by: org.jboss.soa.esb.services.registry.RegistryException: Invocation exception. null

                at org.jboss.soa.esb.services.registry.RegistryFactory.createRegistry(RegistryFactory.java:121)

                at org.jboss.soa.esb.services.registry.RegistryFactory.getRegistry(RegistryFactory.java:86)

                at org.jboss.soa.esb.listeners.RegistryUtil.getEprs(RegistryUtil.java:220)

                at org.jboss.soa.esb.client.ServiceInvoker.loadServiceClusterInfo(ServiceInvoker.java:532)

                ... 4 more

            Caused by: java.lang.NullPointerException

                at java.lang.Class.forName0(Native Method)

                at java.lang.Class.forName(Class.java:247)

                at org.jboss.soa.esb.util.ClassUtil.forName(ClassUtil.java:65)

                at org.jboss.soa.esb.services.registry.RegistryFactory.createRegistry(RegistryFactory.java:110)

                ... 7 more

            {code}

            • 3. Re: Use of ServiceInvoker to test an ESB service
              mageshbk

              Looks like your ESB runtime is not setup properly. It is not able to load the Registry implementation class.

              • 4. Re: Use of ServiceInvoker to test an ESB service
                bfitzpat

                Hmmm... I'm just using the runtime contained in a SOA-P 5.1 instance. What else would I need to do?

                • 5. Re: Use of ServiceInvoker to test an ESB service
                  bfitzpat

                  Based on some Google searches, maybe it has to do with my jbossesb-properties.xml file... Where should that appear in my JBoss ESB project? esbcontent folder? esbcontent/META-INF folder?

                   

                  And what (if any) options do I need to update locally in that file?

                  • 6. Re: Use of ServiceInvoker to test an ESB service
                    jeffdelong

                    Brian,

                     

                    If you look at any of the quickstarts, you see several files at the root of the folder: jbossesb-properties.xml, jndi.properties, and log4j.xml. This first tells the service invoker how to connect to the registry, and the second how to look up the JMS queue in the JNDI service. These need to be on the classpath of your ESB aware client, not inside the esbcontent folder. The esbcontent folder contains the files that get deployed in the esb archive to the server.

                    1 of 1 people found this helpful
                    • 7. Re: Use of ServiceInvoker to test an ESB service
                      mageshbk
                      Based on some Google searches, maybe it has to do with my jbossesb-properties.xml file... Where should that appear in my JBoss ESB project? esbcontent folder? esbcontent/META-INF folder?

                      At the root of your project.

                       

                      And what (if any) options do I need to update locally in that file?

                      Nothing.

                      • 8. Re: Use of ServiceInvoker to test an ESB service
                        bfitzpat

                        Thanks Jeff. That got me a bit farther... Now I'm seeing this:

                         

                        {code}

                        Exception in thread "main" org.jboss.soa.esb.listeners.message.MessageDeliverException: org.apache.ws.scout.transport.TransportException: java.lang.Exception: Cannot locate configuration source META-INF/uddi.xml

                            at org.jboss.soa.esb.client.ServiceInvoker.loadServiceClusterInfo(ServiceInvoker.java:545)

                            at org.jboss.soa.esb.client.ServiceInvoker.<init>(ServiceInvoker.java:174)

                            at org.jboss.soa.esb.client.ServiceInvoker.<init>(ServiceInvoker.java:155)

                            at org.jboss.soa.esb.client.ServiceInvoker.<init>(ServiceInvoker.java:197)

                            at org.jboss.soa.esb.samples.quickstart.aggregator.test.SendEsbMessage.main(SendEsbMessage.java:70)

                        Caused by: org.jboss.soa.esb.services.registry.RegistryException: org.apache.ws.scout.transport.TransportException: java.lang.Exception: Cannot locate configuration source META-INF/uddi.xml

                            at org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl.findEPRs(JAXRRegistryImpl.java:358)

                            at org.jboss.internal.soa.esb.services.registry.InVMRegistryInterceptor.findEPRs(InVMRegistryInterceptor.java:85)

                            at org.jboss.soa.esb.services.registry.RegistryFactory$HeadRegistryInterceptor.findEPRs(RegistryFactory.java:229)

                            at org.jboss.soa.esb.listeners.RegistryUtil.getEprs(RegistryUtil.java:226)

                            at org.jboss.soa.esb.client.ServiceInvoker.loadServiceClusterInfo(ServiceInvoker.java:532)

                            ... 4 more

                        Caused by: javax.xml.registry.JAXRException: org.apache.ws.scout.transport.TransportException: java.lang.Exception: Cannot locate configuration source META-INF/uddi.xml

                            at org.apache.ws.scout.registry.BusinessQueryManagerV3Impl.findConcepts(BusinessQueryManagerV3Impl.java:535)

                            at org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl.getJBossESBTModel(JAXRRegistryImpl.java:795)

                            at org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl.findEPRs(JAXRRegistryImpl.java:327)

                            ... 8 more

                        {code}

                        • 9. Re: Use of ServiceInvoker to test an ESB service
                          mageshbk

                          Did you try adding an empty uddi.xml?

                          • 10. Re: Use of ServiceInvoker to test an ESB service
                            bfitzpat

                            I tried putting it in the esbcontent/META-INF directory and it still complained about it.

                            • 11. Re: Use of ServiceInvoker to test an ESB service
                              bfitzpat

                              Looks like it's in the right place in the deployed service (META-INF), so it may just be that it doesn't like the empty file.

                              • 12. Re: Use of ServiceInvoker to test an ESB service
                                jeffdelong

                                The files in esbcontent are for the ESB Service. These other files need to be at the root of the classpath for the ESB aware client. The file you need is in quickstarts/conf/registry/META-INF/uddi.xml. This is picked up by the quickstarts that use an ESB Aware Client. In previous versions of the ESB there was a juddi.properties that was in each quickstart. I forgot to mention it in my earlier post; when it got moved it kind of got lost. Sorry about that So copy /META-INF/uddi.xml from quickstarts/conf/registry to the root of your project (or into src folder, whatever gets in on your run classpath).

                                 

                                ESB Aware clients are a pain because of all the files and jars that need to be on the classpath. This is one reason why I switched to using web service clients to test services (and another reason to expose services as web services).

                                • 13. Re: Use of ServiceInvoker to test an ESB service
                                  bfitzpat

                                  @Jeff - Thanks for pointing out where to grab that file. But even with that file being deployed in the right place, I'm still getting this:

                                   

                                  {code}

                                  Exception in thread "main" org.jboss.soa.esb.listeners.message.MessageDeliverException: org.apache.ws.scout.transport.TransportException: java.lang.Exception: Cannot locate configuration source META-INF/uddi.xml

                                      at org.jboss.soa.esb.client.ServiceInvoker.loadServiceClusterInfo(ServiceInvoker.java:545)

                                      at org.jboss.soa.esb.client.ServiceInvoker.<init>(ServiceInvoker.java:174)

                                      at org.jboss.soa.esb.client.ServiceInvoker.<init>(ServiceInvoker.java:155)

                                      at org.jboss.soa.esb.client.ServiceInvoker.<init>(ServiceInvoker.java:197)

                                      at org.jboss.soa.esb.samples.quickstart.aggregator.test.SendEsbMessage.main(SendEsbMessage.java:70)

                                  Caused by: org.jboss.soa.esb.services.registry.RegistryException: org.apache.ws.scout.transport.TransportException: java.lang.Exception: Cannot locate configuration source META-INF/uddi.xml

                                      at org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl.findEPRs(JAXRRegistryImpl.java:358)

                                      at org.jboss.internal.soa.esb.services.registry.InVMRegistryInterceptor.findEPRs(InVMRegistryInterceptor.java:85)

                                      at org.jboss.soa.esb.services.registry.RegistryFactory$HeadRegistryInterceptor.findEPRs(RegistryFactory.java:229)

                                      at org.jboss.soa.esb.listeners.RegistryUtil.getEprs(RegistryUtil.java:226)

                                      at org.jboss.soa.esb.client.ServiceInvoker.loadServiceClusterInfo(ServiceInvoker.java:532)

                                      ... 4 more

                                  Caused by: javax.xml.registry.JAXRException: org.apache.ws.scout.transport.TransportException: java.lang.Exception: Cannot locate configuration source META-INF/uddi.xml

                                      at org.apache.ws.scout.registry.BusinessQueryManagerV3Impl.findConcepts(BusinessQueryManagerV3Impl.java:535)

                                      at org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl.getJBossESBTModel(JAXRRegistryImpl.java:795)

                                      at org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl.findEPRs(JAXRRegistryImpl.java:327)

                                      ... 8 more

                                  {/code}

                                  • 14. Re: Use of ServiceInvoker to test an ESB service
                                    tcunning

                                    I think Brian solved this, but this thread is very useful in figuring out issues in getting a ServiceInvoker example working :

                                     

                                    http://community.jboss.org/message/527147

                                    1 2 Previous Next