1 2 Previous Next 17 Replies Latest reply: Aug 4, 2013 7:14 AM by Lakshman Kumar RSS

    Accessing HornetQ using remote lookup via JNDI

    ~= ziggy =~ Newbie

      I am using Jboss 7.1.0 and been reading about how to connect to a JMS queue on Jboss using HornetQ.

      Most of the documentation i see seems to suggest that remote access to anything other than remote EJBs, via JNDI,  is not supported in any of the released AS7 versions.

       

      I have a standalone application that runs outside of the Jboss application server that needs to retrieve messages (Non EJB) from the HornetQ/JMS queue using JNDI. Is this not possible?

        • 1. Re: Accessing HornetQ using remote lookup via JNDI
          Justin Bertram Master

          You can look-up JMS artifacts in JNDI on JBoss AS 7.1.0.Final from a remote client using code like this:

           

                  final Properties env = new Properties();

                  env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");

                  env.put(Context.PROVIDER_URL, "remote://localhost:4447");

                  env.put(Context.SECURITY_PRINCIPAL, "guest");

                  env.put(Context.SECURITY_CREDENTIALS, "pass");

                  Context context = new InitialContext(env);

                  ConnectionFactory cf = (ConnectionFactory) context.lookup("jms/RemoteConnectionFactory");

                  Destination destination = (Destination) context.lookup("jms/queue/test");

                  context.close();

          • 2. Re: Accessing HornetQ using remote lookup via JNDI
            ~= ziggy =~ Newbie

            Thanks Justin i have tried your suggestion with a simple client test. Here is my configuration:

             

            HornetQ config ($JBOSS_HOME/standalone/configuration/standalone-full.xml

             

            <jms-destinations>

                <jms-queue name="testQueue">

                  <entry name="queue/test"/>

                  <entry name="java:jboss/exported/jms/queue/test"/>

                </jms-queue>

                <jms-topic name="testTopic">

                  <entry name="topic/test"/>

                  <entry name="java:jboss/exported/jms/topic/test"/>

                </jms-topic>

            </jms-destinations>


            The Test client properties

             

             

             

                        final Properties env = new Properties();

                  env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");

                  env.put(Context.PROVIDER_URL, "remote://localhost:4447");

                  env.put(Context.SECURITY_PRINCIPAL, "appuser");

                  env.put(Context.SECURITY_CREDENTIALS, "secret");

             

             


            I can see that the Hornet Queue was started when I started up Jboss

             

            19:12:52,331 INFO [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-3) Server is now live

            19:12:52,341 INFO [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-3) HornetQ Server version 2.2.11.Final (HQ_2_2_11_FINAL_AS7, 122) [19944b54-6491-11e1-b996-be5320524153]) started

            19:12:52,353 INFO [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-1) trying to deploy queue jms.queue.testQueue

            19:12:52,405 INFO  [org.jboss.as.messaging] (MSC service thread 1-1) JBAS011601: Bound messaging object to jndi name java:/queue/test

            19:12:52,480 INFO  [org.jboss.as.messaging] (MSC service thread 1-1) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/queue/test

            19:12:52,662 INFO  [org.jboss.as.messaging] (MSC service thread 1-8) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/RemoteConnectionFactory

            19:12:52,667 INFO  [org.jboss.as.messaging] (MSC service thread 1-8) JBAS011601: Bound messaging object to jndi name java:/RemoteConnectionFactory

            19:12:52,672 INFO [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-2) trying to deploy queue jms.topic.testTopic

            19:12:52,864 INFO  [org.jboss.as.messaging] (MSC service thread 1-2) JBAS011601: Bound messaging object to jndi name java:/topic/test

            19:12:52,868 INFO  [org.jboss.as.messaging] (MSC service thread 1-2) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/topic/test

            19:12:52,893 INFO  [org.jboss.as.messaging] (MSC service thread 1-3) JBAS011601: Bound messaging object to jndi name java:/ConnectionFactory

            19:12:52,987 INFO  [org.jboss.as.deployment.connector] (MSC service thread 1-7) JBAS010406: Registered connection factory java:/JmsXA

            19:12:53,019 INFO  [org.hornetq.ra.HornetQResourceAdapter] (MSC service thread 1-7) HornetQ resource adaptor started

            19:12:53,027 INFO [org.jboss.as.connector.services.ResourceAdapterActivatorService$ResourceAdapterActivator] (MSC service thread 1-7) IJ020002: Deployed: file://RaActivatorhornetq-ra

            19:12:53,038 INFO  [org.jboss.as.deployment.connector] (MSC service thread 1-8) JBAS010401: Bound JCA ConnectionFactory [java:/JmsXA]

            19:12:53,134 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: JBoss AS 7.1.0.Final "Thunder" started in 24015ms - Started 168 of 244 services (75 services are passive or on-demand)

            19:22:01,001 INFO  [org.jboss.as.naming] (Remoting "btp060430" task-4) JBAS011806: Channel end notification received, closing channel Channel ID 613aa287 (inbound) of Remoting connection 009ee6a0 to /127.0.0.1:54180

            19:22:01,366 ERROR [org.jboss.remoting.remote.connection] (Remoting "btp060430" read-1) JBREM000200: Remote connection failed: java.io.IOException: An existing connection was forcibly closed by the remote host

            19:32:27,997 INFO  [org.jboss.as.naming] (Remoting "btp060430" task-3) JBAS011806: Channel end notification received, closing channel Channel ID 716fab73 (inbound) of Remoting connection 01ecdc36 to /127.0.0.1:54204

            19:32:28,338 ERROR [org.jboss.remoting.remote.connection] (Remoting "btp060430" read-1) JBREM000200: Remote connection failed: java.io.IOException: An existing connection was forcibly closed by the remote host

            19:33:26,850 INFO  [org.jboss.as.naming] (Remoting "btp060430" task-2) JBAS011806: Channel end notification received, closing channel Channel ID 59baeb73 (inbound) of Remoting connection 01a82c48 to /127.0.0.1:54211

            19:33:27,231 ERROR [org.jboss.remoting.remote.connection] (Remoting "btp060430" read-1) JBREM000200: Remote connection failed: java.io.IOException: An existing connection was forcibly closed by the remote host

            19:35:44,464 INFO  [org.jboss.as.naming] (Remoting "btp060430" task-1) JBAS011806: Channel end notification received, closing channel Channel ID 3a79742b (inbound) of Remoting connection 001ab167 to /127.0.0.1:54219

            19:35:44,813 ERROR [org.jboss.remoting.remote.connection] (Remoting "btp060430" read-1) JBREM000200: Remote connection failed: java.io.IOException: An existing connection was forcibly closed by the remote host

            19:37:34,987 INFO  [org.jboss.as.naming] (Remoting "btp060430" task-4) JBAS011806: Channel end notification received, closing channel Channel ID 18c06edd (inbound) of Remoting connection 01322c02 to /127.0.0.1:54232

            19:37:35,394 ERROR [org.jboss.remoting.remote.connection] (Remoting "btp060430" read-1) JBREM000200: Remote connection failed: java.io.IOException: An existing connection was forcibly closed by the remote host

            19:38:27,074 INFO  [org.jboss.as.naming] (Remoting "btp060430" task-3) JBAS011806: Channel end notification received, closing channel Channel ID 3b946004 (inbound) of Remoting connection 01ab6497 to /127.0.0.1:54238

            19:38:27,454 ERROR [org.jboss.remoting.remote.connection] (Remoting "btp060430" read-1) JBREM000200: Remote connection failed: java.io.IOException: An existing connection was forcibly closed by the remote host

             

            The error that I see

             

            log4j:WARN No appenders could be found for logger (org.jboss.logging).

            log4j:WARN Please initialize the log4j system properly.

            1. javax.naming.NameNotFoundException: queue/test -- service jboss.naming.context.java.jboss.exported.queue.test

                   at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:97)

                   at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:177)

                   at org.jboss.naming.remote.protocol.v1.Protocol$1.handleServerMessage(Protocol.java:124)

                   at org.jboss.naming.remote.protocol.v1.RemoteNamingServerV1$MessageReciever$1.run(RemoteNamingServerV1.java:70)

                   at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)

                   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)

                   at java.lang.Thread.run(Thread.java:619)

            • 3. Re: Accessing HornetQ using remote lookup via JNDI
              Justin Bertram Master

              The NameNotFoundException looks accurate to me since you are trying lookup "queue/test" instead of "jms/queue/test" as I indicated in my previous comment.

               

              The ERRORs you see on the server are some kind of JBoss Remoting bug that I think should be ironed out in 7.1.1.  You should be able to safely ignore them.

              • 4. Re: Accessing HornetQ using remote lookup via JNDI
                ~= ziggy =~ Newbie

                Thanks Justin it is working now. Yes i saw the report on the errors on the server so i was ignoring those for now.

                Is it possible to temporarily connect without these two properties?

                 

                env.put(Context.SECURITY_PRINCIPAL, "appuser");

                env.put(Context.SECURITY_CREDENTIALS, "passw0rd");

                 

                If i try to connect without them it comes up with an "authentication failure". Is it possible to disable the authentication so that i dont need to provide the username and password properties?

                • 5. Re: Accessing HornetQ using remote lookup via JNDI
                  Justin Bertram Master

                  Yes, it is possible to disable this security.  Simply remove the "security-realm" from the "remoting-connector" <connector>.  Here is what the default looks like:

                   

                          <subsystem xmlns="urn:jboss:domain:remoting:1.1">

                              <connector name="remoting-connector" socket-binding="remoting" security-realm="ApplicationRealm"/>

                          </subsystem>

                   

                  Change it to be like this:

                   

                          <subsystem xmlns="urn:jboss:domain:remoting:1.1">

                              <connector name="remoting-connector" socket-binding="remoting"/>

                          </subsystem>

                  • 6. Re: Accessing HornetQ using remote lookup via JNDI
                    ~= ziggy =~ Newbie

                    Hi Justin,

                     

                    I removed the ApplicationRealm from the remoting-connector. It now looks like this

                     

                    <subsystem xmlns="urn:jboss:domain:remoting:1.1">

                                <connector name="remoting-connector" socket-binding="remoting"/>

                    </subsystem>

                     

                    I also changed the HornetQ security configuration to disable security as described here http://docs.jboss.org/hornetq/2.2.5.Final/user-manual/en/html/security.html

                    I added the <security-enabled> entry so my hornetq configuration looks like this

                     

                    <hornetq-server>

                                   

                                    ...

                                    ...

                                    <journal-file-size>102400</journal-file-size>

                                    <journal-min-files>2</journal-min-files>

                                    <security-enabled>false</false>

                                    <connectors>

                                        <netty-connector name="netty" socket-binding="messaging"/>

                                        <netty-connector name="netty-throughput" socket-binding="messaging-throughput">

                                            <param key="batch-delay" value="50"/>

                                        </netty-connector>

                                        <in-vm-connector name="in-vm" server-id="0"/>

                                    </connectors>              

                                    ...

                                    ...

                                    <security-settings>

                                        <security-setting match="#">

                                            <permission type="send" roles="guest"/>

                                            <permission type="consume" roles="guest"/>

                                            <permission type="createNonDurableQueue" roles="guest"/>

                                            <permission type="deleteNonDurableQueue" roles="guest"/>

                                        </security-setting>

                                    </security-settings>             

                                    ...

                                    ...

                                </hornetq-server>

                     

                    When i run the client using the following properties:

                     

                            final Properties env = new Properties();
                            env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
                            env.put(Context.PROVIDER_URL, "remote://localhost:4447");
                    

                     

                    I get the following error:

                     

                    javax.naming.NamingException: Failed to create remoting connection [Root exception is java.lang.RuntimeException: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed]

                        at org.jboss.naming.remote.client.ClientUtil.namingException(ClientUtil.java:36)

                        at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:117)

                        at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)

                        at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)

                        at javax.naming.InitialContext.init(InitialContext.java:223)

                        at javax.naming.InitialContext.<init>(InitialContext.java:197)

                        at com.jms.client.ConsoleClient.runExample(ConsoleClient.java:45)

                        at com.jms.client.ConsoleClient.main(ConsoleClient.java:20)

                    Caused by: java.lang.RuntimeException: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed

                        at org.jboss.naming.remote.protocol.IoFutureHelper.get(IoFutureHelper.java:87)

                        at org.jboss.naming.remote.client.cache.ConnectionCache.get(ConnectionCache.java:42)

                        at org.jboss.naming.remote.client.InitialContextFactory.createConnection(InitialContextFactory.java:153)

                        at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateConnection(InitialContextFactory.java:126)

                        at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:106)

                        ... 6 more

                    Caused by: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed

                        at org.jboss.remoting3.remote.ClientConnectionOpenListener$Capabilities.handleEvent(ClientConnectionOpenListener.java:365)

                        at org.jboss.remoting3.remote.ClientConnectionOpenListener$Capabilities.handleEvent(ClientConnectionOpenListener.java:214)

                        at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:72)

                        at org.xnio.channels.TranslatingSuspendableChannel.handleReadable(TranslatingSuspendableChannel.java:189)

                        at org.xnio.channels.TranslatingSuspendableChannel$1.handleEvent(TranslatingSuspendableChannel.java:103)

                        at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:72)

                        at org.xnio.nio.NioHandle.run(NioHandle.java:90)

                        at org.xnio.nio.WorkerThread.run(WorkerThread.java:184)

                        at ...asynchronous invocation...(Unknown Source)

                        at org.jboss.remoting3.EndpointImpl.doConnect(EndpointImpl.java:270)

                        at org.jboss.remoting3.EndpointImpl.doConnect(EndpointImpl.java:251)

                        at org.jboss.remoting3.EndpointImpl.connect(EndpointImpl.java:349)

                        at org.jboss.remoting3.EndpointImpl.connect(EndpointImpl.java:333)

                        at org.jboss.naming.remote.client.cache.EndpointCache$EndpointWrapper.connect(EndpointCache.java:110)

                        at org.jboss.naming.remote.client.cache.ConnectionCache.get(ConnectionCache.java:41)

                     

                    If i change the connection properties to the following then it does work.

                     

                            final Properties env = new Properties();

                            env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");

                            env.put(Context.PROVIDER_URL, "remote://localhost:4447");

                            env.put(Context.SECURITY_PRINCIPAL, "appuser2");

                            env.put(Context.SECURITY_CREDENTIALS, "s3cret");

                     

                    So it works if i provide the username and password and revert the security changes i described above but it doesnt work if i apply the security changes and dont provide the username and password. What else do i need to do to get it to work without having to provide the username and password.

                     

                    Thanks.

                    • 7. Re: Accessing HornetQ using remote lookup via JNDI
                      Rahat Ali Newbie

                      Hello I am using jboss 7.1 final release. I am trying to look up JMS Ques by providing the

                              env.put(Context.PROVIDER_URL, "jnp://localhost:5445"); but I get a strange error

                      JNDI API lookup failed: javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost:5445 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to retrieve stub from server localhost/127.0.0.1:5445 [Root exception is java.io.EOFException]]

                      javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost:5445 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to retrieve stub from server localhost/127.0.0.1:5445 [Root exception is java.io.EOFException]]

                          at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1763)

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

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

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

                          at com.sanmar.notification.jms.SanMarMessageProducer.main(SanMarMessageProducer.java:181)

                      Caused by: javax.naming.CommunicationException: Failed to retrieve stub from server localhost/127.0.0.1:5445 [Root exception is java.io.EOFException]

                          at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:327)

                          at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1734)

                          ... 4 more

                      Caused by: java.io.EOFException

                          at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2281)

                          at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2750)

                          at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:780)

                          at java.io.ObjectInputStream.<init>(ObjectInputStream.java:280)

                          at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:312)

                          ... 5 more

                       

                      if I try to provide Provider_URL=remote://localhost:4447 then it says host not found. I checked my standalone-full.xml there messaging port is 5445 so I am using this port instead of remote port. Can you guide me what I am doing wrong?

                      • 8. Re: Accessing HornetQ using remote lookup via JNDI
                        Justin Bertram Master

                        You cannot do JNDI lookups on port 5445.  That is the port used for Netty connections for HornetQ.  You need to use port 4447.

                         

                        If you're getting errors when trying to use remote://localhost:4447 then I recommend you open a thread on the AS7 forum.  HornetQ is not responsible for JNDI, the application server itself is.

                        • 9. Re: Accessing HornetQ using remote lookup via JNDI
                          Rahat Ali Newbie

                          Justin, thank you for your reply. I am able to run JMS with HornetQ on my local machine. I have successfully pushed messages to JMS queue and received as well when I was on my local machine the same client with same properties is unable to create connection when I take it to other network  machine. The exception I see is SaslException. Can you guide me on this.

                           

                           

                          ERROR: JBREM000200: Remote connection failed: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed

                          javax.naming.NamingException: Failed to create remoting connection [Root exception is java.lang.RuntimeException: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed]

                              at org.jboss.naming.remote.client.ClientUtil.namingException(ClientUtil.java:36)

                              at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:117)

                              at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684)

                              at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:305)

                              at javax.naming.InitialContext.init(InitialContext.java:240)

                              at javax.naming.InitialContext.<init>(InitialContext.java:214)

                              at com.sanmar.notification.jms.context.JMSContextManager.getContext(JMSContextManager.java:27)

                              at com.sanmar.notification.jms.SanMarMessageProducer.<clinit>(SanMarMessageProducer.java:28)

                          Caused by: java.lang.RuntimeException: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed

                              at org.jboss.naming.remote.protocol.IoFutureHelper.get(IoFutureHelper.java:87)

                              at org.jboss.naming.remote.client.cache.ConnectionCache.get(ConnectionCache.java:42)

                              at org.jboss.naming.remote.client.InitialContextFactory.createConnection(InitialContextFactory.java:153)

                              at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateConnection(InitialContextFactory.java:126)

                              at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:106)

                              ... 6 more

                          Caused by: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed

                              at org.jboss.remoting3.remote.ClientConnectionOpenListener$Capabilities.handleEvent(ClientConnectionOpenListener.java:365)

                              at org.jboss.remoting3.remote.ClientConnectionOpenListener$Capabilities.handleEvent(ClientConnectionOpenListener.java:214)

                              at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:72)

                              at org.xnio.channels.TranslatingSuspendableChannel.handleReadable(TranslatingSuspendableChannel.java:189)

                              at org.xnio.channels.TranslatingSuspendableChannel$1.handleEvent(TranslatingSuspendableChannel.java:103)

                              at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:72)

                              at org.xnio.nio.NioHandle.run(NioHandle.java:90)

                              at org.xnio.nio.WorkerThread.run(WorkerThread.java:184)

                              at ...asynchronous invocation...(Unknown Source)

                              at org.jboss.remoting3.EndpointImpl.doConnect(EndpointImpl.java:270)

                              at org.jboss.remoting3.EndpointImpl.doConnect(EndpointImpl.java:251)

                              at org.jboss.remoting3.EndpointImpl.connect(EndpointImpl.java:349)

                              at org.jboss.remoting3.EndpointImpl.connect(EndpointImpl.java:333)

                              at org.jboss.naming.remote.client.cache.EndpointCache$EndpointWrapper.connect(EndpointCache.java:110)

                              at org.jboss.naming.remote.client.cache.ConnectionCache.get(ConnectionCache.java:41)

                              ... 9 more

                          Exception in thread "main" java.lang.NullPointerException

                              at com.sanmar.notification.jms.SanMarMessageProducer.sendMessage(SanMarMessageProducer.java:45)

                              at com.sanmar.notification.jms.SanMarMessageProducer.main(SanMarMessageProducer.java:68)

                           

                           

                           

                          Let me share my client properties here

                           

                          java.naming.factory.initial=org.jboss.naming.remote.client.InitialContextFactory

                          java.naming.provider.url=remote://localhost:4447

                          java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

                          java.naming.security.principal=appuser

                          java.naming.security.credentials=pwd

                           

                          I have tried the following properties as well which was not part of my properties earlier.

                           

                          remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false

                          remote.connections=default

                          remote.connection.two.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false

                          remote.connection.default.username=appuser

                          remote.connection.default.password=pwd

                           

                          But none of the thing worked for Remote JNDI look up.

                          • 10. Re: Accessing HornetQ using remote lookup via JNDI
                            Justin Bertram Master

                            The javax.security.sasl.SaslException thrown by JBoss Remoting 3 code indicates that your JNDI authentication has failed.  Please ensure that the credentials (i.e. appuser/pwd) used in your JNDI look-up are valid for the server to which you are connecting.  Also, I don't believe that security is enforced on a local client (i.e. a client running on the same machine as the server, though not necessarily in the same JVM) by default so the fact that it works when you're connecting to 'localhost' doesn't necessarily mean these credentials are valid.  You can use the <JBOSS_HOME>/bin/add-user.sh script to add users.  JNDI uses the "ApplicationRealm".

                            • 11. Re: Accessing HornetQ using remote lookup via JNDI
                              Valentijn Scholten Newbie

                              Rahat Ali wrote:

                               

                              Justin, thank you for your reply. I am able to run JMS with HornetQ on my local machine. I have successfully pushed messages to JMS queue and received as well when I was on my local machine the same client with same properties is unable to create connection when I take it to other network  machine. The exception I see is SaslException. Can you guide me on this.

                               

                               

                              ERROR: JBREM000200: Remote connection failed: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed

                              javax.naming.NamingException: Failed to create remoting connection [Root exception is java.lang.RuntimeException: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed]

                                  at org.jboss.naming.remote.client.ClientUtil.namingException(ClientUtil.java:36)

                                  at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:117)

                               

                              Hello Rahat Ali,

                               

                              Did you manage to resolve you issue? I am having the same issue that it works locally, but not remotely.

                              • 12. Re: Accessing HornetQ using remote lookup via JNDI
                                Justin Bertram Master

                                If you're having issues take a look at http://www.jboss.org/jdf/quickstarts/jboss-as-quickstart/helloworld-jms/.  It's a full working example with documentation.

                                • 13. Re: Accessing HornetQ using remote lookup via JNDI
                                  Valentijn Scholten Newbie

                                  Thanks, but I am already beyond that.

                                   

                                  Like I say the application is working perfectly when the client is connecting to a JMS queue on the same machine.

                                  The jboss instance MDBs pick up the message, process it and put a response on the response queueu.

                                  the client sees the responses and everything is workig perfect.

                                   

                                  However when I move the client to a different machine, it stops working.

                                   

                                  I tried to disable security, to try to create a connection with and without the username and password. It just doesn't work.

                                   

                                  Depending on the settings I choose I am getting the JBREM000200 connection mentioned above or sometimes just the message that it can't connect to the server.

                                  • 14. Re: Accessing HornetQ using remote lookup via JNDI
                                    Justin Bertram Master

                                    I tried to disable security...

                                    What exactly did you do to try to disable security?  Keep in mind that any remote client doing a JNDI lookup and working with JMS resources is actually working with 2 discrete subsystems (i.e. naming and messaging) which each have their own independent security mechanisms.

                                     

                                     

                                    ...to try to create a connection with and without the username and password. It just doesn't work.

                                    What exactly doesn't work?  Are you receiving an exception?  If so, what is the stack trace?  Can you share the client code?

                                     

                                     

                                    Depending on the settings I choose I am getting the JBREM000200 connection mentioned above or sometimes just the message that it can't connect to the server.

                                    What specific settings do you choose and what is the exact result for each variation?

                                     

                                     

                                    Have you added an application user?  If so, are you passing those credentials for both the JNDI look-up and JMS createConnection?

                                    1 2 Previous Next