10 Replies Latest reply on May 16, 2007 5:42 AM by kconner

    How to use ESB under WEB Application ?

    mhammam

      Hi;

      I want to use JBoss ESb under WEB application.

      It is possible ? if yes, how to make it ?

      Thank's for your response.

        • 1. Re: How to use ESB under WEB Application ?
          tfennelly

          Hi there.

          Can you supply more details please? What exactly do you mean by "use under WEB application"?

          If you're asking does the ESB support exposing HTTP endpoints, then the answer is yes - through the JBossRemotingGatewayListener. I'm only aware of 2 quickstarts (from the MR2 release) that demonstrate this - "webservice_jbossws_adapter_01" and "webservice_bpel".

          • 2. Re: How to use ESB under WEB Application ?
            mhammam

            Hi,

            I use ESB to scan root directory and get all files, and i want to send those files to my web application.

            ESB service is .sar directory in JBoss SA, and my web application is .war directory.

            so, i want to use classe located in the .war/myapplication/lib.

            so the question is, how can ESB use classe located in jar file out of jbosesb.sar ?

            I dont want to use webservices for this.

            Thank's in advance.

            • 3. Re: How to use ESB under WEB Application ?
              tfennelly

              So, if I'm reading you correctly, you want the ability to HTTP POST data to an external HTTP endpoint (your web app), from the ESB??

              If this is what you're looking for, I'm fairly sure we don't have it right now, but we will have it soon (by 4.2GA). We have an immediate need for this in the BPEL/Webservices area.

              If you want to contribute something on this to the project, we'd be more than grateful :-)

              • 4. Re: How to use ESB under WEB Application ?
                mhammam

                I want to use java classe at the endpoint of JBoss ESB.and this classe is in .war directory.

                • 5. Re: How to use ESB under WEB Application ?
                  tfennelly

                  OK, sorry... this is an AS classloader scoping issue....
                  http://www.jboss.org/wiki/Wiki.jsp?page=JBossClassLoadingUseCases

                  • 6. Re: How to use ESB under WEB Application ?
                    burrsutter

                    Unfortunately we don't have a quickstart that illustrates the WAR deployment option.

                    Perhaps you could experiment with the right classpath/structure for getting everything running in a WAR and then make note of the steps required to make this easier going forward.

                    Our default deployment model is as a .ESB archive (like a WAR or EAR) or standalone in its own JVM. You see these options used in the helloworld quickstart ("ant run" for standalone, "ant deploy" for .esb archive).

                    • 7. Re: How to use ESB under WEB Application ?
                      mhammam

                      Hi,

                      Can you more explain to me please, how to make this purpose ?

                      10x.

                      • 8. Re: How to use ESB under WEB Application ?
                        kconner

                        You can create a base war distribution by executing the ant 'tomcat' target from within the install directory.

                        Once this has been created you can add your own libraries/classes/esb config to this distribution.

                        A number of the QSes have been tested using the WAR deployer, these are listed in this JIRA task.

                        Outstanding work is documented in JIRA

                        • 9. Re: How to use ESB under WEB Application ?
                          mhammam

                          When i deply the jbosesb.war under jbossweb-tomcat55.sar, the following error was shown :

                          15:27:05,968 WARN [ServiceController] Problem starting service jboss.web.deployment:war=jbossesb.war,id=-1937630021
                          org.jboss.deployment.DeploymentException: Error during deploy; - nested throwable: (javax.naming.NamingException: resource-ref: jdbc/juddiDB has no valid JNDI binding. Check the jboss-web/resource-ref.)

                          • 10. Re: How to use ESB under WEB Application ?
                            kconner

                            Apologies, I assumed you were wanting to deploy the ESB into a Tomcat instance.

                            The error you are seeing is occurring because the specification of the datasource binding is different in tomcat than it is in AS but, as the ESB should already be deployed, this should not required.

                            You should be able to access the ESB classes within AS provided that the sar is deployed, all that is left is to configure the ESB deployment.

                            To configure the ESB you will need to do add something similar to the following within your codebase

                            package org.jboss.soa.esb.servlet;
                            
                            import java.io.IOException;
                            import java.io.InputStream;
                            
                            import javax.servlet.ServletContext;
                            import javax.servlet.ServletContextEvent;
                            import javax.servlet.ServletContextListener;
                            
                            import org.jboss.soa.esb.listeners.config.Configuration;
                            import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleController;
                            import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleException;
                            
                            /**
                             * Context listener used to configure a partial ESB in a war environment.
                             * @author kevin
                             */
                            public class WarConfigListener implements ServletContextListener
                            {
                             /**
                             * The lifecycle controller.
                             */
                             private ManagedLifecycleController lifecycleController ;
                            
                             /**
                             * Initialise the ESB.
                             * @param servletContextEvent The initialised context event.
                             */
                             public void contextInitialized(final ServletContextEvent servletContextEvent)
                             {
                             final ServletContext servletContext = servletContextEvent.getServletContext() ;
                            
                             servletContext.log("Initialising ESB Configuration Controller") ;
                            
                             final String esbConfigResource = "META-INF/jboss-esb.xml" ;
                             final InputStream configIS = servletContext.getResourceAsStream(esbConfigResource) ;
                             if (configIS == null)
                             {
                             servletContext.log("Could not locate ESB configuration resource: " + esbConfigResource) ;
                             }
                             else
                             {
                             String config ;
                             try
                             {
                             config = Configuration.getStringFromStream(configIS) ;
                             }
                             catch (final Exception ex)
                             {
                             config = null ;
                             servletContext.log("Failed to read ESB configuration resource: " + esbConfigResource, ex) ;
                             }
                             finally
                             {
                             try
                             {
                             configIS.close() ;
                             }
                             catch (final IOException ex) {} // ignore
                             }
                             if (config != null)
                             {
                             final ManagedLifecycleController lifecycleController = Configuration.create(config) ;
                             servletContext.log("ESB starting") ;
                             try
                             {
                             lifecycleController.start() ;
                             this.lifecycleController = lifecycleController ;
                             servletContext.log("ESB started") ;
                             }
                             catch (final ManagedLifecycleException mle)
                             {
                             servletContext.log("Failed to start ESB", mle) ;
                             }
                             }
                             }
                             }
                            
                             /**
                             * Terminate the ESB.
                             * @param servletContextEvent The destroyed context event.
                             */
                             public void contextDestroyed(final ServletContextEvent servletContextEvent)
                             {
                             if (lifecycleController != null)
                             {
                             final ServletContext servletContext = servletContextEvent.getServletContext() ;
                            
                             servletContext.log("ESB stopping") ;
                            
                             try
                             {
                             lifecycleController.stop() ;
                             servletContext.log("ESB stopped") ;
                             }
                             catch (final ManagedLifecycleException mle)
                             {
                             servletContext.log("Failed to stop ESB", mle) ;
                             }
                             }
                             }
                            }
                            

                            This should work if you add the listener to your web.xml and create the META-INF/jboss-esb.xml configuration. I should add that it is untested, I have just written it :-), and that this code will be unnecessary for the GA release.

                            Your war file should only contain your dependencies, not the ESB jars.

                            Let me know how this works, email me with any problems.