-
1. Re: hornetq jms
jbertram Jul 23, 2012 10:25 AM (in response to jjgrego)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:
- MDB init/ctor logging.
- JNDI look-up from the client.
- 2-way SSL.
-
2. Re: hornetq jms
jjgrego Jul 23, 2012 11:03 AM (in response to jbertram)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 Jul 23, 2012 1:33 PM (in response to jjgrego)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 Jul 23, 2012 2:53 PM (in response to jbertram)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 Jul 23, 2012 2:58 PM (in response to jjgrego)Couple of questions..
- Can you paste the full exception here?
- Are there any errors in the server's log?
- To what interface are you binding the server (e.g. using the "-b" command line option)?
- Does it work with JAAS and SSL when the client and server are on the same machine?
-
6. Re: hornetq jms
jjgrego Jul 23, 2012 3:10 PM (in response to jbertram)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 Jul 23, 2012 3:50 PM (in response to jbertram)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 Jul 23, 2012 5:31 PM (in response to jjgrego)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 Jul 24, 2012 8:01 AM (in response to jbertram)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 Jul 24, 2012 10:43 AM (in response to jjgrego)Can you attach myjbosstest.Main? It looks like it is just trying to connect to the wrong host.
-
11. Re: hornetq jms
jjgrego Jul 24, 2012 10:51 AM (in response to jbertram)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 Jul 24, 2012 10:55 AM (in response to jjgrego)All I really need to see is what properties you are passing to the InitialContext.
-
13. Re: hornetq jms
jjgrego Jul 24, 2012 12:11 PM (in response to jbertram)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 Jul 24, 2012 1:04 PM (in response to jjgrego)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.).