10 Replies Latest reply on Feb 14, 2008 5:00 PM by Michal Suchecki

    helloworld in eclipse

    Stephen Varey Newbie

      Hi,

      I am new to JBoss ESB.

      I have successfully installed jbossesb and run the first hello world
      example using ant.

      running ant sendesb works fine.
      When I build a project in eclipse and try to run SendEsbMessage as a console application
      I get the following error.




      0 [main] DEBUG org.jboss.soa.esb.services.registry.RegistryFactory - Going to load org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl
      0 [main] DEBUG org.jboss.soa.esb.common.Factory - Using the Context ClassLoader
      172 [main] DEBUG org.jboss.soa.esb.services.registry.RegistryFactory - Going to load org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl
      172 [main] DEBUG org.jboss.soa.esb.common.Factory - Using the Context ClassLoader
      Exception in thread "main" java.lang.NullPointerException
      at java.util.Hashtable.put(Unknown Source)
      at java.util.Properties.setProperty(Unknown Source)
      at org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl.init(JAXRRegistryImpl.java:81)
      at org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl.getConnection(JAXRRegistryImpl.java:96)
      at org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl.findEPRs(JAXRRegistryImpl.java:315)
      at org.jboss.soa.esb.listeners.ListenerUtil.tryToDeliver(ListenerUtil.java:63)
      at quickstart.helloworld.test.SendEsbMessage.main(SendEsbMessage.java:196)




      I am passing these runtime arguments to java

      -Dorg.jboss.soa.esb.registry.queryManagerURI="org.apache.juddi.registry.local.InquiryService#inquire"
      -Dorg.jboss.soa.esb.registry.lifeCycleManagerURI="org.apache.juddi.registry.local.PublishService#publish"
      -Dorg.jboss.soa.esb.registry.implementationClass="org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl"
      -Dorg.jboss.soa.esb.registry.factoryClass="org.apache.ws.scout.registry.ConnectionFactoryImpl"
      -Dorg.jboss.soa.esb.registry.user=jbossesb
      -Dorg.jboss.soa.esb.registry.password=password

      Are there other properties I need to set to setup the correct runtime environment?

      Thanks
      Stephen

        • 1. Re: helloworld in eclipse
          Daniel Brum Novice

          I think you should just be able to add the juddi.properties file into your classpath inside of Eclipse. I'm not sure that's related to the error you are seeing, you would need to paste some of the code involved in the trace you pasted.

          • 2. Re: helloworld in eclipse
            Stephen Varey Newbie

            I have gone back to the original source in the helloworld directory.
            No changes except in the runtime params.

            The error is...log4j:WARN No appenders could be found for logger (org.jboss.soa.esb.services.registry.RegistryFactory).
            log4j:WARN Please initialize the log4j system properly.
            Exception in thread "main" org.jboss.soa.esb.services.registry.RegistryException
            at org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl.findEPRs(JAXRRegistryImpl.java:332)
            at org.jboss.soa.esb.listeners.ListenerUtil.tryToDeliver(ListenerUtil.java:63)
            at quickstart.helloworld.test.SendEsbMessage.main(SendEsbMessage.java:60)
            Caused by: java.lang.NullPointerException
            at org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl.findService(JAXRRegistryImpl.java:429)
            at org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl.findEPRs(JAXRRegistryImpl.java:317)
            ... 2 more


            now.

            My current settings for the JVM are show below although I this is just guess work as I can't figure out from the documentation what I need to do to get the example to work in eclipse.

            -Dorg.jboss.soa.esb.registry.queryManagerURI=org.apache.juddi.registry.local.InquiryService#inquire
            -Dorg.jboss.soa.esb.registry.lifeCycleManagerURI=org.apache.juddi.registry.local.PublishService#publish
            -Dorg.jboss.soa.esb.registry.implementationClass=org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl
            -Dorg.jboss.soa.esb.registry.factoryClass=org.apache.ws.scout.registry.ConnectionFactoryImpl
            -Dorg.jboss.soa.esb.registry.user=jbossesb
            -Dorg.jboss.soa.esb.registry.password=password
            -Dorg.jboss.soa.esb.jndi.server.type=jboss
            -Dorg.jboss.soa.esb.jndi.server.url=localhost
            -Dorg.jboss.soa.esb.persistence.connection.factory=org.jboss.internal.soa.esb.persistence.format.MessageStoreFactoryImpl
            -Dorg.jboss.soa.esb.scout.proxy.transportClass=org.apache.ws.scout.transport.RMITransport
            -Djuddi.jdbcDriver=com.mysql.jdbc.Driver
            -Djuddi.jdbcUrl=jdbc:mysql://localhost/juddi
            -Djuddi.isUseDataSource=true
            -Djuddi.dataSource=java:comp/env/jdbc/juddiDB
            -Djava.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
            -Djava.naming.provider.url=jnp://localhost:1099
            -Djava.naming.factory.url.pkgs=org.jboss.naming



            • 3. Re: helloworld in eclipse
              Daniel Brum Novice

              I forgot to mention, under the IDE folder from the root, we include the eclipse project/classpath files you can use to import the codebase directly into eclipse. It's meant for JBossIDE, but you can use it with a plain Eclipse as well, just update the classpath to include the Drools library reference which is bundled inside of JBossIDE. That will get all of the code loaded with all examples and trailblazer.

              • 4. Re: helloworld in eclipse
                Kurt Stam Master

                There are two property files: jbossesb-properties.xml and juddi.properties. There should be no need to use system parameters.

                If you want the debugger to work I suggest using the JBossIDE, deploy the ESB to JBossAS and start JBossAS from within the IDE. This will solve the problem of getting all property and config files in the right place.

                Cheers,

                --Kurt

                • 5. Re: helloworld in eclipse
                  Stephen Varey Newbie

                  You are correct. I did away with all system params and put jbossesb-properties.xml and juddi.properties on the classpath which work fine.
                  The original program sendesbmessage.java still does not work out of the box though (from eclipse that is). The error message is

                  Exception in thread "main" org.jboss.soa.esb.services.registry.RegistryException
                  at org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl.findEPRs(JAXRRegistryImpl.java:332)
                  at org.jboss.soa.esb.listeners.ListenerUtil.tryToDeliver(ListenerUtil.java:63)
                  at quickstart.helloworld.test.SendEsbMessage.main(SendEsbMessage.java:70)
                  Caused by: java.lang.NullPointerException
                  at org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl.findService(JAXRRegistryImpl.java:429)
                  at org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl.findEPRs(JAXRRegistryImpl.java:317)
                  ... 2 more


                  When I insert 2 extra lines in the source

                  Registry registry = RegistryFactory.getRegistry();
                  Collection services = registry.findAllServices();


                  the following error happens

                  Exception in thread "main" java.lang.NullPointerException
                  at org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl.findOrganization(JAXRRegistryImpl.java:380)
                  at org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl.getJBossESBOrganization(JAXRRegistryImpl.java:634)
                  at org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl.findAllServices(JAXRRegistryImpl.java:277)
                  at quickstart.helloworld.test.SendEsbMessage.main(SendEsbMessage.java:65)


                  The 3 program params are exactly as in the build.xml
                  FirstServiceESB, SimpleListener, Hello World - Straight to ESB listener - no Gateway

                  • 6. Re: helloworld in eclipse
                    Stephen Varey Newbie

                    With reference to my last reply I added log4j logging and got a little more relating to the problem

                    0 [main] DEBUG org.jboss.soa.esb.services.registry.RegistryFactory - Going to load org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl
                    0 [main] DEBUG org.jboss.soa.esb.common.Factory - Using the Context ClassLoader
                    31 [main] ERROR org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl - Could not set up a connection to the Registry. Failed to create instance of: null
                    javax.xml.registry.JAXRException: Failed to create instance of: null
                    at javax.xml.registry.ConnectionFactory.newInstance(ConnectionFactory.java:75)
                    at org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl.getConnection(JAXRRegistryImpl.java:99)
                    at org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl.findOrganization(JAXRRegistryImpl.java:377)
                    at org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl.getJBossESBOrganization(JAXRRegistryImpl.java:634)
                    at org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl.findAllServices(JAXRRegistryImpl.java:277)
                    at quickstart.helloworld.test.SendEsbMessage.main(SendEsbMessage.java:73)
                    Caused by: java.lang.NullPointerException
                    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
                    at java.lang.ClassLoader.loadClass(Unknown Source)
                    at javax.xml.registry.ConnectionFactory.newInstance(ConnectionFactory.java:70)
                    ... 5 more
                    Exception in thread "main" java.lang.NullPointerException
                    at org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl.findOrganization(JAXRRegistryImpl.java:380)
                    at org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl.getJBossESBOrganization(JAXRRegistryImpl.java:634)
                    at org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl.findAllServices(JAXRRegistryImpl.java:277)
                    at quickstart.helloworld.test.SendEsbMessage.main(SendEsbMessage.java:73)

                    • 7. Re: helloworld in eclipse
                      Kurt Stam Master

                      I've put together a pdf to run the HelloWorld in the JBossIDE. See http://wiki.jboss.org/wiki/attach?page=JBossESBJBossIDE%2FJBossIDE-HelloWorld.pdf

                      I hope this helps

                      Cheers,

                      --Kurt

                      • 8. Re: helloworld in eclipse
                        Stephen Varey Newbie

                        Kurt

                        Thanks for the effort in writing that pdf. Great job It wasn't quite what I wanted but it will be very very help nonetheless and I am glad I discovered the jboss ide.
                        Nevertheless I would still like to run the sendesb message as an application from the menu "run as application". When I select the file to do that the dialog "selection does not contain a main type" pops up. I have not modified the source code at all and my goal is simply to run this program as a java app but invoked from eclipse and not ant. Only that way can I see all the dependencies and jars i need if I want to make this run outside of jboss ide and jboss ant scripts..

                        • 9. Re: helloworld in eclipse
                          Kurt Stam Master

                          Hi Stephen,

                          With the eclipse project you got following the instructions I posted, now replace the content of the .classpath file with:

                          <?xml version="1.0" encoding="UTF-8"?>
                          <classpath>
                           <classpathentry kind="src" path="samples/quickstarts/helloworld/src"/>
                           <classpathentry excluding="src/" kind="src" path="samples/quickstarts/helloworld"/>
                           <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
                           <classpathentry kind="lib" path="lib/ext/jaxr-api-1.0-SNAPSHOT.jar"/>
                           <classpathentry kind="lib" path="lib/ext/scout-1.0-SNAPSHOT.jar"/>
                           <classpathentry kind="lib" path="lib/ext/jbossts-common.jar"/>
                           <classpathentry kind="lib" path="lib/jbossesb-rosetta.jar"/>
                           <classpathentry kind="lib" path="lib/jbossesb-listeners.jar"/>
                           <classpathentry kind="lib" path="lib/jbossesb-services.jar"/>
                           <classpathentry kind="lib" path="lib/ext/log4j.jar"/>
                           <classpathentry kind="lib" path="lib/ext/jbossall-client.jar"/>
                           <classpathentry kind="lib" path="lib/ext/xbean.jar"/>
                           <classpathentry kind="lib" path="lib/ext/commons-logging.jar"/>
                           <classpathentry kind="lib" path="lib/ext/stax-api-1.0.1.jar"/>
                           <classpathentry kind="lib" path="lib/ext/juddi-client-1.0-SNAPSHOT.jar"/>
                           <classpathentry kind="lib" path="lib/ext/xercesImpl-2.7.1.jar"/>
                           <classpathentry kind="output" path="bin"/>
                          </classpath>
                          


                          Note that the order of the jars matters.

                          And when you run the sendesb as application give it the arguments:
                          FirstServiceESB SimpleListener Hello

                          On the console of the server you should now see:

                          01:24:39,781 INFO [STDOUT] &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
                          01:24:40,812 INFO [STDOUT]
                          Body: Hello
                          01:24:42,437 INFO [STDOUT]
                          &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

                          Which means you successfully delivered an EsbMessage directly to the service.

                          Also note that your jbossas (with jbossesb) server needs to be running.

                          --Kurt


                          • 10. Re: helloworld in eclipse
                            Michal Suchecki Newbie

                            Hi gscf,
                            did you make it work? I'm facing same problem.

                            After setting my classpath (almost) as Kurt suggested I get:

                            DEBUG RMITransport - Initial Context using env={java.naming.provider.url=null://null:-1, java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming}
                            DEBUG RMITransport - Calling service=org.apache.juddi.registry.local.InquiryService, Class = null, Method=inquire
                            DEBUG NamingContext - Failed to connect to null:1099
                            javax.naming.CommunicationException: Failed to connect to server null:1099

                            Michal Suchecki