6 Replies Latest reply on Aug 21, 2017 4:12 PM by George Berish

    What is correct JNDI name format for Remote Context.lookup() by remote Java Client?

    George Berish Novice

        Can Anyone tell me why all of these JNDI names for a JMS Queue cause Context.lookup() to throw:

            javax.naming.NameNotFoundException ?

       

      I’m working to resurrect an old Eclipse-Luna/Wildfly-8 project with Eclipse-Neon/WildFly-10. 

       

      I know the strategy for Context.lookup() from a remote client (i.e. one outside the Wildfly container) has changed a lot over time.

      I just can’t find the one I need to use today. These all fail.

       

      java:/jms/queue/goSendToClientQueue

      java:jboss/exported/jms/queue/goSendToClientQueueX

      java:jboss/remote/jms/queue/goSendToClientQueueZ

       

      Here’s what I pasted below:

       

      -- The CLI console output when I added the Queues to standalone-full.xml.

      -- The lines it added to standalone-full.xml.

      -- The relevant part of my code leading up to the lookup().

      -- The Eclipse Console output for one try that threw the NotFoundException

       

      Note 1: I think Console confirms I have a valid InitialContext. Can lookup() a ConnectionFactory. Has a valid Connections. And valid Session.

      Note 2: All runs have identical Console output except for the JNDI name that fails).

      Note 3: In my code

                  P() is a helper method I use to simplify printing to System.out.

                  TK is a helper class that lets me put my InitialContext Properties in and external file.

                  Both let me make my Eclipse Console output easy to follow.

       

      CLI Command Line Output to Set Up Queues:

      -----

      c) 2017 Microsoft Corporation. All rights reserved.

      C:\ProgramFilesGeo\Wildfly\wildfly-10.1.0.Final\bin>jboss-cli.bat

      You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands.

      [disconnected /] connect

       

      [standalone@localhost:9990 /] /subsystem=messaging-activemq/server=default/jms-queue=goSendToClientQueue:add(entries=[java:/jms/qu

      eue/goSendToClientQueue])

      {"outcome" => "success"}

       

      standalone@localhost:9990 /] /subsystem=messaging-activemq/server=default/jms-queue=goSendToClientQueueX:add(entries=[java:jboss/

      exported/jms/queue/goSendToClientQueueX])

      {"outcome" => "success"}

       

      [standalone@localhost:9990 /] /subsystem=messaging-activemq/server=default/jms-queue=goSendToClientQueueZ:add(entries=[java:jboss/

      remote/jms/queue/goSendToClientQueueZ])

      {"outcome" => "success"}

      [standalone@localhost:9990 /]

      -----

       

      FROM standalone-full.xml

      <subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0">

          <server name="default">

            ...

              <jms-queue name="ExpiryQueue" entries="java:/jms/queue/ExpiryQueue"/>

              <jms-queue name="DLQ" entries="java:/jms/queue/DLQ"/>

              <jms-queue name="goSendToClientQueue" entries="java:/jms/queue/goSendToClientQueue"/>

              <jms-queue name="goSendToClientQueueX" entries="java:jboss/exported/jms/queue/goSendToClientQueueX"/>

              <jms-queue name="goSendToClientQueueZ" entries="java:jboss/remote/jms/queue/goSendToClientQueueZ"/>

       

              <connection-factory name="InVmConnectionFactory" entries="java:/ConnectionFactory" connectors="in-vm"/>

              <connection-factory name="RemoteConnectionFactory" entries="java:jboss/exported/jms/RemoteConnectionFactory" connectors="http-connector"/>

              <pooled-connection-factory name="activemq-ra" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory" connectors="in-vm" transaction="xa"/>

          </server>

      </subsystem>

       

      MY CODE:

      public void run () {

           ...

           P(iAmM + "beg");

           try {

      //get InitialContext Properties

             P(s + iAmM + "Requesting InitialContext");

             Properties env = TK.getEnvironmentVariablesFor(LOCAL);

      //print InitialContext Properties

             P(TK.printInitialContextProperties(LOCAL));

      //get InitialContext Properties

             Context ctx = new InitialContext(env);

             P(s + iAmM + "InitialContext           : OK - " + ctx);

      //Check InitalContext

             P(s + iAmM + "List InitialContext NameClassPairs");

             NamingEnumeration<NameClassPair> list = ctx.list("");

                    int ctr = 0;

                    while (list.hasMoreElements()) {

                       ctr++;

               NameClassPair next = list.next();

               String name = next.getName();

               String className = next.getClassName();

               String sx = "000" + ctr;

               P(s + iAmM + "  [" + ("000" + sx).substring(sx.length()) + "] " + name + " - " + className);

             }

             P(s + iAmM + "End List InitialContext NameClassPairs");

      // get ConnectionFactory

             P(s + iAmM + "Lookingup ConnectionFactory");

             ConnectionFactory factory = (ConnectionFactory)    ctx.lookup("jms/RemoteConnectionFactory");

             P(s + iAmM + "ConnectionFactory: Ok -  " + factory );

      // get JMS connection

             P(s + iAmM + "Instantiating Connection");

                    this.jmsConnection = factory.createConnection("appUser", "appUser9#");

             P(s + iAmM + "JMS Connection : " + this.jmsConnection);

      // get Session

                   this.jmsSession = this.jmsConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);

             P(s + iAmM + "JMS Session : " + jmsSession);

      // get Queue

             String recQueueJNDIName = SetupTK.getStringProperty("SendToClientQueue");

             P(s + iAmM + "Lookup Queue w/ JNDI name: [\"" + recQueueJNDIName + "\"]");

             Queue jmsReceiveFmQueue = (Queue) ctx.lookup(recQueueJNDIName);

      //THROWS ERROR

       

      ECLIPSE CONSOLE OUTPUT

      MsgCenterReceive.run ()      beg

        MsgCenterReceive.run ()      Requesting InitialContext

       

      CONNECTION VARIABLES

        key: java.naming.provider.url        

        value: http-remoting://localhost:8080

        key: java.naming.factory.initial     

        value: org.jboss.naming.remote.client.InitialContextFactory

        key: java.naming.security.principal  

        value: appUser

        key: java.naming.security.credentials

        value: appUser9#

       

        MsgCenterReceive.run ()      InitialContext: OK - javax.naming.InitialContext@646d64ab

       

        MsgCenterReceive.run ()      List InitialContext NameClassPairs

        MsgCenterReceive.run ()        [001] jms - javax.naming.Context

        MsgCenterReceive.run ()      End List InitialContext NameClassPairs

       

        MsgCenterReceive.run ()      Lookingup ConnectionFactory

        MsgCenterReceive.run ()      ConnectionFactory: Ok -  ActiveMQConnectionFactory [serverLocator=ServerLocatorImp ... + around 20 more lines of properties]

       

        MsgCenterReceive.run ()      Instantiating Connection

        MsgCenterReceive.run ()      JMS Connection : org.apache.activemq.artemis.jms.client.ActiveMQConnection@24313fcc

       

        MsgCenterReceive.run ()      JMS Session    : ActiveMQSession->ClientSessionImpl [name=d6fcde0c ...]@7d20d0b

       

        MsgCenterReceive.run ()      Lookup Queue w/ JNDI name: ["java:jboss/remote/jms/queue/goSendToClientQueueZ"]

       

        MsgCenterReceive.run ()      caught: javax.naming.NameNotFoundException

        MsgCenterReceive.run ()            : jboss/remote/jms/queue/goSendToClientQueueZ -- service jboss.naming.context.java.jboss.exported.jboss.remote.jms.queue.goSendToClientQueueZ

       

      1. MsgCenterReceive.run ()      end
        • 1. Re: What is correct JNDI name format for Remote Context.lookup() by remote Java Client?
          Miroslav Novak Master

          If you need to lookup any object outside of WF10 JVM then you need to register it under "java:jboss/exported/..." context like "java:jboss/exported/jms/queue/myQueue" and then look it up like "jms/queue/myQueue".

           

          Mirek

          • 2. Re: What is correct JNDI name format for Remote Context.lookup() by remote Java Client?
            George Berish Novice

            Thank you.

            For others here’s my complete test:

             

            CLI COMMAND WINDOW TO CREATE TestQueue8

            ------------

            Microsoft Windows [Version 10.0.15063]

            (c) 2017 Microsoft Corporation. All rights reserved.

             

            <[wildfly-10.1.0.Final]\bin>jboss-cli.bat

            You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands.

            [disconnected /] connect

             

            [standalone@localhost:9990 /] /subsystem=messaging-activemq/server=default/jms-queue=TestQueue8:add(

            entries=[java:jboss/exported/jms/queue/TestQueue8])

             

            {"outcome" => "success"}

            [standalone@localhost:9990 /]

            ---------------------------

             

            Standalone-full.xml AFTER ADDING TEST QUEUE

             

            <subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0">

              <server name="default">

               

                <jms-queue name="TestQueue8" entries="java:jboss/exported/jms/queue/TestQueue8"/>

             

                <connection-factory name="InVmConnectionFactory" entries="java:/ConnectionFactory" connectors="in-vm"/>

                <connection-factory name="RemoteConnectionFactory" entries="java:jboss/exported/jms/RemoteConnectionFactory" connectors="http-connector"/>

                <pooled-connection-factory name="activemq-ra" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory" connectors="in-vm" transaction="xa"/>

              </server>

            </subsystem>

             

            Code that worked:

            Queue jmsReceiveFmQueue = (Queue) ctx.lookup("jms/queue/TestQueue8");

            • 3. Re: What is correct JNDI name format for Remote Context.lookup() by remote Java Client?
              Miroslav Novak Master

              Thanks George for those question. I guess that in the next step you will hit problem with security on Artemis. You'll need to disable security in Artemis (there is attributed security-enabled in messaging-activemq subsystem) or to configure rights for role (of your user) in security-settings.

              • 4. Re: What is correct JNDI name format for Remote Context.lookup() by remote Java Client?
                George Berish Novice

                Hi,

                 

                Thank you for the warning, and all your help.

                 

                But can you tell me if the problem you mention would show by making a call to Session createConsumer() throw a java.lang.NullPointerException which of course createConsumer() is not supposed to be able to do?

                 

                George

                --------------------------------------

                PS: I know its a bit off topic ... but just in case anyone who follows gets this far with my problem, the next thing that happened after Mirek's solution allowed me to obtain a Queue is that my call to Session createConsumer() did in fact throw a  java.lang.NullPointerException

                Weird, so I posted my code and output below to show that it really did..

                 

                [I know its an insane amount of extraneous print code, but I couldn’t figure out any other way to prove to myself that createConsumer() really did throw it

                ... or ... dunno ... Is coming from some other thread?

                But please notice: Both e.getSource() and e.getMessage() are NULL which is really frustrating.

                Else: P () is just my helper for System.out.println().

                “iAmM” is just the name of my Class.which I took out of the console, because it's long and doesn't help  readers ]

                 

                CODE:

                   public void run () {

                     boolean p = true; String iAmM = null; String s = "  ";

                     if (p) iAmM = Utility.getIAmM(Thread.currentThread().getStackTrace()).substring(0, 25);

                     if (p) Utility.upMargin ();

                     if (p) P(iAmM + "beg");

                     try {

                       if (p) P(s + iAmM + "Requesting InitialContext\n");

                       Properties env = ConnectionToolkit.getEnvironmentVariablesFor(LOCAL);

                       if (p) P(ConnectionToolkit.printInitialContextProperties(LOCAL));

                       Context ctx = new InitialContext(env); // Set Wildfly Initial Context

                       P("\n" + s + iAmM + "InitialContext OK: " + ctx);

                 

                       /*

                        * get ConnectionFactory;

                        */

                       String f = SetupTK.getStringProperty("JmsConnectionFactory");

                       if (p) P("\n" + s + iAmM + "Look up ConnectionFactory with: \"" + f + "\"");

                       ConnectionFactory factory = (ConnectionFactory) ctx.lookup("jms/RemoteConnectionFactory");

                       if (p) P(s + iAmM + "ConnectionFactory: Ok -  " + factory );

                       /*

                        * get JMS connection

                        */

                       if (p) P("\n" + s + iAmM + "Instantiating Connection");

                       this.jmsConnection = factory.createConnection("appUser", "appUser9#");

                       if (p) P(s + iAmM + "JMS Connection ok: " + this.jmsConnection);

                       /*

                        * get Session

                        */

                      

                       if (p) P("\n" + s + iAmM + "Instantiating Session");

                       this.jmsSession = this.jmsConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);

                       if (p) P(s + iAmM + "JMS Session ok: " + jmsSession);

                       /*

                        * get Send to Server and Send to Client Queues

                        */

                 

                       if (p) P("\n" + s + iAmM + "Getting Send to Client and Send to Server Queues");

                       String toServerQ = "SendToServerQueue";

                       String toServerJNDI = SetupTK.getStringProperty(toServerQ);

                       if (p) P("\n" + s + iAmM + "Lookup Queue w/ JNDI name: [\"" + toServerJNDI + "\"]");

                       Queue jmsSendToServerQueue = (Queue) ctx.lookup(toServerJNDI);

                       if(p) P(s + iAmM + "Queue secured: " + jmsSendToServerQueue

                           + (jmsSendToServerQueue==null?"IS NULL": "IS NOT NULL") );

                 

                       String toClientQ = "SendToClientQueue";

                       String toClientJNDI = SetupTK.getStringProperty(toClientQ);

                       if (p) P("\n" + s + iAmM + "Lookup Queue w/ JNDI name: [\"" + toClientJNDI + "\"]");

                       Queue jmsSendToClientQueue = (Queue) ctx.lookup(toClientJNDI);

                       if(p) P(s + iAmM + "Queue secured: " + jmsSendToClientQueue

                           + (jmsSendToClientQueue==null?"IS NULL": "IS NOT NULL") );

                     

                       if (p) P("\n" + s + iAmM + "Calling:"

                             + "this.jmsSession.createConsumer(jmsSendToClientQueue, this.jmsSelector)");

                 

                       if (p) P(s + iAmM + "this.jmsSelector: " + this.jmsSelector);

                       if (p) P(s + iAmM + "jmsSendToClientQueue.toString(): " + jmsSendToClientQueue.toString());

                       this.jmsMsgConsumer = this.jmsSession.createConsumer(jmsSendToClientQueue, this.jmsSelector);

                       if (p) P(s + iAmM + "GOT PAST createConsumer()");

                 

                       if (p) P(iAmM + "end - ok");

                      if (p) Utility.downMargin();

                      ok = true;

                     } catch (CommunicationException e) {

                       if (p) P(s + iAmM + "Caught: " + e.getClass().getName());

                       if (p) P(s + iAmM + "Msg:    " + e.getMessage());

                       if (p) P(s + iAmM + "Cause:  " + e.getCause());

                       if (p) P(iAmM + "end - error 1");

                       if (p) Utility.downMargin();

                       ok = false;

                     } catch (Exception e) {

                       if (!p) iAmM = Utility.getIAmM(Thread.currentThread().getStackTrace());

                       if (!p) Utility.upMargin ();

                       P(s + iAmM + "caught :  " + e.getClass().getName());

                       P(s + iAmM + "Msg    : " + e.getMessage());

                       P(s + iAmM + "Source :  " + e.getMessage());

                       P(iAmM + "end - error 2");

                       Utility.downMargin();

                       ok = false;

                     }

                   }

                 

                CONSOLE OUTPUT:

                <iAmM>.run ()  beg

                  <iAmM>.run ()  Requesting InitialContext

                      CONNECTION VARIABLES

                        key: java.naming.provider.url

                          value: http-remoting://localhost:8080

                        key: java.naming.factory.initial

                          value: org.jboss.naming.remote.client.InitialContextFactory

                        key: java.naming.security.principal

                          value: appUser

                        key: java.naming.security.credentials

                          value: appUser9#

                  <iAmM>.run ()  InitialContext OK: javax.naming.InitialContext@646d64ab

                 

                  <iAmM>.run ()  Look up ConnectionFactory with: "jms/RemoteConnectionFactory"

                    <iAmM>.run ()  ConnectionFactory: Ok -  ActiveMQConnectionFactory [... , readOnly=false]

                 

                  <iAmM>.run ()  Instantiating Connection

                  <iAmM>.run ()  JMS Connection ok: org.apache.activemq.artemis.jms.client.ActiveMQConnection@247bddad

                 

                  <iAmM>.run ()  Instantiating Session

                  <iAmM>.run ()  JMS Session ok: ActiveMQSession->ClientSessionImpl [name=1c7c45f2...]@d35dea7

                 

                  <iAmM>.run ()  Getting Send to Client and Send to Server Queues

                 

                  <iAmM>.run ()  Lookup Queue w/ JNDI name: ["jms/queue/sendToServerQueue"]

                  <iAmM>.run ()  Queue secured: ActiveMQQueue[SendToServerQueue]IS NOT NULL

                 

                  <iAmM>.run ()  Lookup Queue w/ JNDI name: ["jms/queue/sendToClientQueue"]

                  <iAmM>.run ()  Queue secured: ActiveMQQueue[SendToClientQueue]IS NOT NULL

                 

                  <iAmM>.run ()  Calling:this.jmsSession.createConsumer(jmsSendToClientQueue, this.jmsSelector)

                  <iAmM>.run ()  this.jmsSelector: selector='aaaaaa'

                  <iAmM>.run ()  jmsSendToClientQueue.toString(): ActiveMQQueue[SendToClientQueue]

                 

                  <iAmM>.run ()  caught : java.lang.NullPointerException

                  <iAmM>.run ()  Msg :  null

                  <iAmM>.run ()  Source : null

                <iAmM>.run ()  end - error 2

                • 6. Re: What is correct JNDI name format for Remote Context.lookup() by remote Java Client?
                  George Berish Novice

                  Hi Mirek,

                   

                  My full console output is below w/ stack trace

                  Followed by my code.

                  Followed by a list of all the jars in the class path (although I suspect a few are unneeded)

                   

                  NOTE: I’ve condensed everything into a single new test Class below.

                   

                  I've added an insane number of print lines to remove all ambiguity about where the Exception comes from.

                   

                  But if you strip out irrelevant print code, and ignore static methods that are just print helpers this is what's running:

                   

                  7 RELEVANT MAIN () LINES:

                  Context ctx = new InitialContext(ENV);

                  ConnectionFactory factory = (ConnectionFactory) ctx.lookup("jms/RemoteConnectionFactory");

                  Connection jmsConnection = factory.createConnection(ENV.getProperty(Context.SECURITY_PRINCIPAL), ENV.getProperty(Context.SECURITY_CREDENTIALS));

                  jmsConnection.start();

                  Session jmsSession = jmsConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);

                  Queue jmsSendToClientQueue = (Queue)    ctx.lookup("jms/queue/sendToClientQueue");

                  MessageConsumer jmsMsgConsumer = jmsSession.createConsumer(jmsSendToClientQueue, JMS_SELECTOR);

                   

                  NOTE: [All the other static methods are print helpers I normally import from a utility class, but pasted here so the test class is free standing. I.e. so the next poor newbie could just cut, past and run it as a starting point.]

                   

                  CONOSLE OUTPUT W/ STACK TRACE

                  TestArtemisJmsWF10.main ()                   beg

                      TestArtemisJmsWF10.main ()                   Requesting InitialContext with:

                          CONNECTION VARIABLES

                          key: java.naming.provider.url         value: http-remoting://localhost:8080

                          key: java.naming.factory.initial      value: org.jboss.naming.remote.client.InitialContextFactory

                          key: java.naming.security.principal   value: jmsUser

                          key: java.naming.security.credentials value: jmsUser123!

                      TestArtemisJmsWF10.main ()                   InitialContext ok: javax.naming.InitialContext@4bbfb90a

                   

                      TestArtemisJmsWF10.main ()                   Lookup ConnectionFactory

                     TestArtemisJmsWF10.main ()                   JNDI lookUp name: "jms/RemoteConnectionFactory"

                     TestArtemisJmsWF10.main ()                   ConnectionFactory: Ok:

                                                                  [org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory]

                     TestArtemisJmsWF10.main ()                   JMS Connection: Ok:

                                                                  [org.apache.activemq.artemis.jms.client.ActiveMQConnection@6f03482]

                   

                     TestArtemisJmsWF10.main ()                   Starting jmsConnection & initiating Session

                     TestArtemisJmsWF10.main ()                   Session ok - ActiveMQSession->ClientSessionImpl [name=cee1fce7-86a2-11e7-a459-3ca9f4beb648,

                                                                    username=jmsUser, closed=false, factory =

                                                                    org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl@35fc6dc4,

                                                                    metaData=(jms-session=,)]@9d5509a

                   

                    TestArtemisJmsWF10.main ()                   Lookup Queue

                    TestArtemisJmsWF10.main ()                   JNDI lookUp name: "jms/queue/sendToClientQueue"

                    TestArtemisJmsWF10.main ()                   Queue secured: org.apache.activemq.artemis.jms.client.ActiveMQQueue

                   

                    TestArtemisJmsWF10.main ()                   Calling createConsumer() with selector: selector='AAAAA'

                    TestArtemisJmsWF10.main ()                   Caught: java.lang.NullPointerException

                                                                          when Creating JMS Message Consumer

                                                                   Msg   : null

                  TestArtemisJmsWF10.main ()               end - error

                  java.lang.NullPointerException

                      at org.apache.activemq.artemis.jms.client.ActiveMQDestination$TYPE.isTemporary(ActiveMQDestination.java:397)

                      at org.apache.activemq.artemis.jms.client.ActiveMQDestination.isTemporary(ActiveMQDestination.java:308)

                      at org.apache.activemq.artemis.jms.client.ActiveMQSession.createConsumer(ActiveMQSession.java:367)

                      at org.apache.activemq.artemis.jms.client.ActiveMQSession.createConsumer(ActiveMQSession.java:350)

                      at org.america3.gotest.xtra.TestArtemisJmsWF10.main(TestArtemisJmsWF10.java:65)

                   

                  FREE STANDING TEST CLASS

                  import java.util.Properties;

                  import javax.naming.Context;

                  import javax.naming.InitialContext;

                  import javax.jms.Connection;

                  import javax.jms.ConnectionFactory;

                  import javax.jms.MessageConsumer;

                  import javax.jms.Queue;

                  import javax.jms.Session;

                   

                  public class TestArtemisJmsWF10 {

                   

                    static final Properties ENV = new Properties() {

                      private static final long serialVersionUID = 1L;

                      {

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

                        put(Context.PROVIDER_URL, "http-remoting://localhost:8080");

                        put(Context.SECURITY_PRINCIPAL, "jmsUser");

                        put(Context.SECURITY_CREDENTIALS, "jmsUser123!");

                      }

                    };

                    static final String JMS_SELECTOR = "selector=\'AAAAA\'";

                   

                    public static void main (String args[]) {

                      boolean p = true; String iAmM = null; String s = "  "; String errAt = "";

                      if (p) iAmM = TestArtemisJmsWF10.getIAm(Thread.currentThread().getStackTrace());

                      if (p) P(iAmM + "beg\n");

                      if (p) P(s + iAmM + "Requesting InitialContext with:");

                      if (p) P(printInitialContextProperties(8, ENV));

                      try {

                        errAt = "Requesting InitialContext";

                        Context ctx = new InitialContext(ENV); // Set Wildfly Initial Context

                        if (p) P("\n" + s + iAmM + "InitialContext ok: " + ctx);

                       

                        errAt = "LookingUp  ConnectionFactory";

                        if (p) P("\n" + s + iAmM + "Lookup ConnectionFactory");

                        if (p) P(s + iAmM + "JNDI lookUp name: \"jms/RemoteConnectionFactory\"");

                        ConnectionFactory factory = (ConnectionFactory) ctx.lookup("jms/RemoteConnectionFactory");

                        if (p) P(s + iAmM + "ConnectionFactory: Ok: " );

                        if (p) P(s + makeMargin(iAmM.length()) + "[" + factory.getClass().getName() +"]");

                       

                        errAt = "Requesting Connection";

                        Connection jmsConnection = factory.createConnection( ENV.getProperty(Context.SECURITY_PRINCIPAL), ENV.getProperty(Context.SECURITY_CREDENTIALS));

                        if (p) P("\n" + s + iAmM + "JMS Connection: Ok:");

                        if (p) P(s + makeMargin(iAmM.length()) + "[" + jmsConnection + "]");

                       

                        if (p) P("\n" + s + iAmM + "Starting jmsConnection & initiating Session");

                        errAt = "Starting Connection";

                        jmsConnection.start();

                        errAt = "Creating Session";

                        Session jmsSession = jmsConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);

                        if (p) P(s + iAmM + "Session ok - " + jmsSession);

                       

                        errAt = "Looking Up Queue";

                        if (p) P("\n" + s + iAmM + "Lookup Queue");

                        if (p) P(s + iAmM + "JNDI lookUp name: \"jms/queue/sendToClientQueue\"");

                        Queue jmsSendToClientQueue = (Queue) ctx.lookup("jms/queue/sendToClientQueue");

                        if(p) P(s + iAmM + "Queue secured: " + jmsSendToClientQueue.getClass().getName());

                   

                        errAt = "Creating JMS Message Consumer";

                        if(p) P("\n" + s + iAmM + "Calling createConsumer() with selector: " + JMS_SELECTOR);

                        MessageConsumer jmsMsgConsumer = jmsSession.createConsumer(jmsSendToClientQueue, JMS_SELECTOR);

                        if(p) P(s + iAmM + "Consumer secured: " + jmsMsgConsumer);

                        if (p) P(iAmM + "end");

                    } catch (Exception e) {

                        if(p) P("\n" + s + iAmM + "Caught: "+ e.getClass().getName()

                            + "\n" + s + makeMargin(iAmM.length()) + "when " + errAt);

                        if(p) P(s + makeMargin(iAmM.length()) + "Msg   : " + e.getMessage());

                        if(p) P(iAmM + "end - error");

                        if (p) e.printStackTrace();

                      }

                    }

                   

                    static public String printInitialContextProperties (int leader, Properties env) {

                      int maxLength = 0;

                      String s = padRight("", leader, ' ');

                      for (Object keyO: env.keySet()) {

                        String key = (String) keyO;

                        maxLength = 1+Math.max(maxLength, key.length());

                      }

                      StringBuffer sb = new StringBuffer ();

                      sb.append(s + "CONNECTION VARIABLES");

                      for (Object keyO: env.keySet()) {

                        String key = padRight((String)keyO, maxLength, ' ');

                        sb.append("\n" + s + "key: " + key + "value: " + env.get(keyO));

                      }

                        return sb.toString();

                      }

                   

                    static public void P (String s) {

                      System.out.println(s); 

                    }

                   

                    static private String getIAm (StackTraceElement[] elements) {

                      StringBuffer sb = new StringBuffer ();

                      sb.append(getClassMethodName(elements));

                      sb.append(" ()");

                      return padRight (sb.toString(), 45, ' ') ;

                    }

                   

                    static public String getClassMethodName (StackTraceElement[] elements) {

                      /* This method finds the 1st org.america3 element from the top

                       * of the stack  */

                      String className = null;

                      for (int i = 0; i < elements.length; i++) {

                        className = elements[i].getClassName ();

                        if (className.startsWith ("org.america3")) {

                          int end = className.lastIndexOf ('.');

                          return className.substring (end + 1) + "." + elements[i].getMethodName ();

                        } else {

                         continue;

                        }

                      }

                    return "no project method found in elements beginning with org.america3" ;

                    }

                   

                    static public String padRight(String s, int width, char c){

                      if (s == null) return "Null String";

                      if(s.length() >= width){

                        return s;

                      } else {

                        StringBuffer sb = new StringBuffer();

                        sb.append (s);

                        for(int i = 0; i < (width - s.length()); i++){

                          sb.append(c);

                        }

                        return sb.toString();

                      }

                    }

                   

                    static public String makeMargin (int padWidth) {

                      StringBuffer sb = new StringBuffer ();

                      for (int i = 0; i < padWidth; i ++) {

                        sb.append(' ');

                      }

                      return sb.toString();

                    }

                  }

                   

                  JARS - Some may be irrelevant

                  xnio-api-3.4.6.Final.jar

                  xnio-nio-3.4.3.Final.jar

                   

                  slf4j-log4j12-1.8.0-alpha2.jar

                  apache-logging-log4j.jar

                   

                  artemis-commons-2.2.0.jar

                  artemis-core-client-2.2.0.jar

                  artemis-jms-client-2.2.0.jar

                  artemis-selector-2.2.0.jar

                   

                  commons-beanutils-1.9.2.jar

                  commons-logging-1.1.1.jar

                  commons-collections-3.2.1.jar

                   

                  netty-all-4.1.9.Final.jar

                   

                  javax.json-1.0.2.jar

                  javax.jms-3.1.2.2.jar

                  javax.mail-1.5.0.jar

                  javax.jms-api-2.0.jar

                   

                  jboss-client.jar

                  jboss-logging-3.1.4.GA.jar

                  jboss-ejb-client-1.0.19.final.jar

                  jboss-marshalling-1.3.15.GA.jar

                  jboss-remoting-4.0.7.Final.jar

                  jboss-remote-naming-2.0.1.Final.jar

                  jboss-remoting-3.2.7.ga.jar

                  jboss-marshalling-river-1.3.14.GA.jar

                   

                  hornetq-jms-client.jar