5 Replies Latest reply on Aug 25, 2010 5:25 AM by azarny

    Using Tomcat with HornetQ

    khanna111

      Hi,

       

      Did go through the list of questions that came up while searching here on "tomcat and hornetq" and have a question of my own.

       

      Was wondering if hornetQ can be used in embedded mode in Tomcat? Do I have to use the hornetq JCA on tomcat?

       

      While following this approach, will I be able to cluster multiple hornetq instances running as part of the VM of multiple tomcat instances? Will I be able to configure failover?

       

      What I need to do:

      I need to use a web container such as Tomcat that runs a servlet engine that recieves a post request and based on that need to put a message in a queue for a consumer. I need persistent messaging with failover in case one or more of the tomcat instances crash.

       

      Please can anybody shed any light? I did go through the "configure section" in the user manual but I am not sure if that will provide all of what I need to do including pooling support.

       

      Thanks

      Gaurav

        • 1. Re: Using Tomcat with HornetQ
          khanna111

          Been reading the documentation and these are the details on the progress so far:

          1. Tried using the Embedded JMS Server Example and that led to "NamingException - Context is read only"

          javax.naming.NamingException: Context is read only
                  at org.apache.naming.NamingContext.checkWritable(NamingContext.java:903)
                  at org.apache.naming.NamingContext.bind(NamingContext.java:831)
                  at org.apache.naming.NamingContext.rebind(NamingContext.java:208)
                  at org.apache.naming.NamingContext.rebind(NamingContext.java:223)
                  at org.jnp.server.NamingBeanImpl.start(NamingBeanImpl.java:184)
                  at src.s1.init(s1.java:84)
                  at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
                  at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:809)
                  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)
                  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
                  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
                  at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
                  at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
                  at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
                  at java.lang.Thread.run(Thread.java:637)

           

          Is there a tomcat-how-to for running this example (perhaps with the jms resource declarations for tomcat) ?

           

          Is there another way around?

           

          Thanks

          Gaurav

          • 2. Re: Using Tomcat with HornetQ
            timfox

            The exception is pretty clear: the context you're passing in when creating the jms server is read only. This is not part of HornetQ (it's an Apache class)

             

            It will need to be read-write if you want HornetQ to load JMS destinations and connection factories into it.

             

            You need to use a proper JNDI implementation that allows you to bind objects into it, or disable JNDI.

            • 3. Re: Using Tomcat with HornetQ
              timfox

              You can use the JBoss JNDI implementation if you like (see the embedded JMS example). Probably you have a jndi.properties on your classpath that is pointing to the Apache implementation instead.

              • 4. Re: Using Tomcat with HornetQ
                khanna111

                Thank you Tim. I'll look for it later since I have moved on to not using JNDI for the prototype.

                 

                I have another questions on clustering that I will post as a separate thread.

                 

                Thanks

                Gaurav

                http://khanna111.com/blog

                • 5. Re: Using Tomcat with HornetQ
                  azarny

                  It can be done with some limitations. See http://wash-inside-out.blogspot.com/2010/08/hornetq-jms-integration-with-tomcat.html for more details.

                  Cheers, Igor