1 2 Previous Next 18 Replies Latest reply on Jul 24, 2012 2:19 PM by jbertram

    hornetq jms

    jjgrego

      We have a jboss as (6.0.0).  Since hornetq is already embedded, I configured it to use jaas, since our jboss

      server has it's own custom authenticator.  Using the examples in the ssl-enabled and jaas folders, it appears

      I've successfully completed the configuration.  I had to work through a couple errors, but finally, jboss started

      without error. 

       

      Next, I wrote a MDB and deployed it to the server.  Presently, all this does is spit out the text in the

      onMessage.  Now, I have some logging in the constructor & init functions, but I don't see this in any

      log files.  There are no errors printing, so I'm not sure if it deployed properly.  I have other beans where

      I do this same similar set up, but the logging prints out.  The difference is it was on a weblogic server...

       

       

      Now, I want to post a message to the queue and see whether the mdb picks it up. 

      I wrote my client mirroring the examples in the hornetq example folder.  One major difference is that

      my client class doesn't extend HornetQExample.  When I create my initial context to do a jndi lookup

      on the queue name, I get an exception that there is "no such object in the table".  When I bring up the

      jboss jmx-console, I can see that this object does in fact exist. 

       

      Our jboss server is sitting on one of our lab machines labvm014.  My client is on labvm025.  I'm guessing there

      is some "other" configuration required, but not certain what that would be.  I need to be able to require it to

      use 2-way ssl, which in my client is the first step. 

       

      In the configuration of the server, I changed all instances of "localhost" to labvm014, as that is the name of the

      machine.

       

      Can anyone shed some light on what I may need to do in order to get this to work??

       

      Thanks,

       

      John

        • 1. Re: hornetq jms
          jbertram

          Let's tackle one issue at a time.  Which is the most important issue for you at this point?  These are the ones I noted:

           

          1. MDB init/ctor logging.
          2. JNDI look-up from the client.
          3. 2-way SSL.
          • 2. Re: hornetq jms
            jjgrego

            Justin,

             

            Thanks for checking in.  I'm at a loss as to what to try here. 

             

            I guess the most important thing is doing a jndi lookup from my standalone client.  I've followed the hornetq configuration for the jaas and ssl-enabled

            examples, so I think I'm good to go there.  At least for now. 

             

            Now, I'm just trying to bind to my queue so I can put a message on it. 

             

            You list 2-way ssl as item 3, but this is requirement.  I've done 2-way ssl before w/weblogic, but not jboss.  I can create a regular queue

            and put messages on it using the regular jboss properties stuff...just never done this with hornetq though. 

             

            Thanks,

             

            John

            • 3. Re: hornetq jms
              jbertram

              I guess the most important thing is doing a jndi lookup from my standalone client.

               

              My understanding is that you have a remote client trying to perform a JNDI lookup on JBoss AS 6 for HornetQ JMS resources.  Is that correct?  If so you should be able to use code like this:

               

              import java.util.Properties; 
              
              import javax.jms.Connection;
              import javax.jms.ConnectionFactory;
              import javax.jms.Destination;
              import javax.jms.Message;
              import javax.jms.MessageProducer;
              import javax.jms.Session;
              import javax.naming.InitialContext;
              
              ...
              Properties props = new Properties();
              props.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
              props.put("java.naming.provider.url", "jnp://127.0.0.1:1099");
              props.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
              
              InitialContext initialcontext = new InitialContext(props);
              ConnectionFactory connectionFactory = (ConnectionFactory) initialcontext.lookup("ConnectionFactory");
              connection = connectionFactory.createConnection();
              Destination destination = (Destination) initialcontext.lookup("/queue/A");
              initialcontext.close();
              Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
              MessageProducer producer = session.createProducer(destination);
              Message msg = session.createTextMessage("example text");
              producer.send(msg);
              connection.close();
              
              • 4. Re: hornetq jms
                jjgrego

                Justin,

                 

                Yes, I have a remote client attempting to do a jndi lookup on a on a jboss AS 6 server to send a message to a hornetq configured queue.

                Prior to configuring hornetq for jaas and ssl-enabling it, the snippet worked, provided my client jboss are on the same machine.  However,

                since my client resides on a different machine, I changed the provider.url to:

                 

                jnp://mytestmachine:1099.

                 

                The resulting naming exception states that it failed to retrieve Naming interface for provider http://mytestmachine:1099

                 

                Not quite sure where it pulled that http.

                 

                John

                • 5. Re: hornetq jms
                  jbertram

                  Couple of questions..

                  1. Can you paste the full exception here?
                  2. Are there any errors in the server's log?
                  3. To what interface are you binding the server (e.g. using the "-b" command line option)?
                  4. Does it work with JAAS and SSL when the client and server are on the same machine?
                  • 6. Re: hornetq jms
                    jjgrego

                    Justin,

                     

                    Nevermind when I said I don't know where it's pulling the http when I passed jnp.  During some digging I changed the name

                    of the initial factory.

                     

                    I've since changed it and now get a different error stating the connection was refused to host 127.0.0.1...

                     

                    John

                    • 7. Re: hornetq jms
                      jjgrego

                      Justin,

                       

                      My client can send a message, provided it is on the same machine...I got it to send one.  I did this by changing the settings

                      to what you had in your snippet above.  My mdb threw all kinds of errors, but I'll look @ those tomorrow.  BTW, when the mdb

                      picked up the message, I saw some of the logging i inserted in the thing...progress.

                       

                      After I finished sending the jms message from the local machine, I went back to my remote client to connect and got a connection

                      exception.  It has to be a remote client because the process that puts the message on the server is a cron job that runs daily to

                      perform updates.

                       

                      As for the stack trace, this machine and my client machines are on different networks and can't be connected.  I'll look at pasting the

                      exception on the remote client tomorrow.

                       

                      This snippet:

                                      <!-- Trying to get JAAS authentication -->
                                      <security-domain>myapp</security-domain>
                                  </hornetq-server>

                       

                      Since I'm using jboss 6, what file do I edit?  I've looked for elements hornetq-server but nothing comes up...it's getting late!

                       

                      Again, appreciate your help.

                       

                      John

                      • 8. Re: hornetq jms
                        jbertram

                        After I finished sending the jms message from the local machine, I went back to my remote client to connect and got a connection exception.

                        That indicates to me that one of three things is wrong:

                        • The client is sending the message to the wrong host.
                        • The network between the client and host is bad.
                        • The server is not configured to bind to the proper network interface and therefore is not visible to the remote client.

                         

                        Since I'm using jboss 6, what file do I edit?  I've looked for elements hornetq-server but nothing comes up...it's getting late!

                        In JBoss AS 6 you need to edit the HornetQSecurityManager bean in hornetq-jboss-beans.xml.  Add this:

                         

                          <property name="securityDomainName">java:/jaas/myapp</property>

                        • 9. Re: hornetq jms
                          jjgrego

                          Justin,

                           

                          Here is the full stack trace.  I had to type it as I had no way of transferring it from one system to the other.

                          Hopefully, you'll see something that sticks out.  I know it won't connect, but what I don't know is why.  The reference

                          to 127.0.0.1 - to me - seems like it's trying to connect to a local jboss vice the remote one

                           

                          Debug - TimesSocketFactory - 87 createSocket, hostAddr: mytestmachine/7.... port: 1099 localAddr: null localPort: 0

                          timeOut: 0

                           

                          Debug - Main - 33 - Exception caught javax.naming.CommunicationException [ Root exception is java.rmi.ConnectionException:

                          Connection refused to host 127.0.0.1; nested exception is

                          java.net.ConnectionException: Connection refused ]

                          javax.naming.CommunicationException [ Root exception is java.rmi.ConnectionException: Connection refused to host 127.0.0.1;

                          nested exception is

                          java.net.ConnectionException: Connection refused ]

                          at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:841)

                          at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:688)

                          at javax.naming.InitialContext.lookup(InitialContext.java:392)

                          at myjbosstest.Main.runExample(Main.java:82)

                          at myjbosstest.Main.main(Main.java:31)

                          Caused by: java.rmi.ConnectionException Connection refused to host 127.0.0.1; nested exception is;

                          java.net.ConnectException: Connection refused

                          at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:601)

                          at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198)

                          at sun.rmi.transport.tcp.TCPChannel newConnection(TCPChannel.java:184)

                          at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:110)

                          at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:178)

                          at java.rmi.server.RemoteObjectInvocationHandler(RemoteObjectInvocationHandler.java:132)

                          at $Proxy0.lookup(Unknown Source)

                          at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:728)

                          ... 4 more

                          Caused by: java.net.ConnectException: Connection refused

                          at java.net.PlainSocketImpl.socketConnect(Native Method)

                          at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)

                          at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)

                          at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)

                          at java.net.PlainSocketImpl.(SocksSocketImpl.java:366)

                          at java.net.Socket.connect(Socket.java:519)

                          at java.net.Socket.connect(Socket.java:469)

                          at java.net.Socket.<init>(Socket.java:366)

                          at java.net.Socket.<init>(Socket.java:180)

                          at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)

                          at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:128)

                          at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:595).

                          ... 11 more

                           

                          John

                          • 10. Re: hornetq jms
                            jbertram

                            Can you attach myjbosstest.Main?  It looks like it is just trying to connect to the wrong host.

                            • 11. Re: hornetq jms
                              jjgrego

                              It'll take a bit, but yes, I can.  It's on the same isolated network as the one with jboss 6 installed.

                              However, it's just a plagarazation of the hornetq ssl-enabled example... modified with my info.  The

                              only difference is I setSSLEnv, which does system.setProperty for keystore and truststore, and maybe

                              modifying the text of the message sent.

                               

                              John

                              • 12. Re: hornetq jms
                                jbertram

                                All I really need to see is what properties you are passing to the InitialContext.

                                • 13. Re: hornetq jms
                                  jjgrego

                                  Justin,

                                   

                                  The properties are listed in a Hashtable<String, String> variable called props. 

                                   

                                  props.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");

                                  props.put("java.naming.provider.url", "jnp://mytestmachine:1099");

                                  props.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");

                                   

                                  I've played around with the provider url, changing it to some of the following:

                                  jnps://mytestmachine:1099

                                  jnp://mytestmachine: 5445 // i got this port # from one of the hornetq configuration files.

                                  https://mytestmachine:21032 // this was from an example I now can't find.  this also changed the type of Naming Context to some HTTP one.

                                   

                                  John

                                  • 14. Re: hornetq jms
                                    jbertram

                                    Despite what you have specified for "java.naming.provider.url" the code is somehow being told to connect to "localhost" instead.  Do you have a jndi.properties file in your classpath anywhere?

                                     

                                    Couple of other points:

                                    • 1099 is the default JNDI port.  5445 is the default HornetQ port.  You can't use the HornetQ port for a JNDI lookup.
                                    • You can't simply swap protocols (i.e. jnps, https, etc.).
                                    1 2 Previous Next