6 Replies Latest reply on Oct 23, 2012 10:07 PM by jaikiran

    Initial context create issue

    thinksteep

      Hi Community,

       

      I am having strange issue with initial context creation.

       

      I have standalone app which sends message to HornetQ.

       

      Because of known issue discussed in the thread https://community.jboss.org/message/735877 (Auto reconnect for remote-naming ), I am completly ignoring the initial context and creating new InitialContext. Still I am getting

       

      Caused by: javax.naming.NamingException: Failed to lookup [Root exception is org

      .jboss.remoting3.NotOpenException: Writes closed]

              at org.jboss.naming.remote.client.ClientUtil.namingException(ClientUtil.

      java:36)

              at org.jboss.naming.remote.protocol.v1.Protocol$1.execute(Protocol.java:

      104)

              at org.jboss.naming.remote.protocol.v1.RemoteNamingStoreV1.lookup(Remote

      NamingStoreV1.java:79)

              at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.jav

      a:79)

              at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.jav

      a:83)

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

       

      Strange this is:

       

      I wrote a simple client program with almost same code and running from netbeans, this code is able to create new initial context on server up, working fine.

       

      One behavioural difference I have observed between two codes is:

       

      SIMPLE CLIENT program returning exception java.lang.RuntimeException: Operation failed with status WAITING while server is down, but my standalone app returning above writes closed message.

       

      I am confused on what is missing. Any help would be appreciated.

       

      Thanks for your time and help.

        • 1. Re: Initial context create issue
          jaikiran

          Which exact version of JBoss AS7? Which version of libraries do you have on the client side? What exactly does your client code look like?

          • 2. Re: Initial context create issue
            thinksteep

            Hi Jaikiran,  JBoss7.1.1Final is the version we are using.

             

            I can't post my Standalone app related code here, because it is multiple files.

             

            Here is the STAND ALONE client (which is shorter version of my standalone app) which is throwing "java.lang.RuntimeException: Operation failed with status WAITING". I think this is fine, but same code not working in my STANDALONE APP.

             

            NOTE: Don't worry about coding practices.This is just test code.


            public class JMSTest extends Thread {

             

                public InitialContext inCtx;

                public QueueSender sender;

                public QueueSession session;

             

                public JMSTest(InitialContext initCtx) {

                    inCtx = initCtx;

                    try {

                        QueueConnectionFactory qcf = (QueueConnectionFactory) inCtx.lookup("jms/RemoteConnectionFactory");

                        Queue que = (Queue) inCtx.lookup("myQueue");

                        QueueConnection conn = qcf.createQueueConnection("user", "pwd");

                        session = conn.createQueueSession(false,

                                QueueSession.AUTO_ACKNOWLEDGE);

                        sender = session.createSender(que);

                    } catch (NamingException ne) {

                        Properties p = new Properties();

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

                        p.put(Context.PROVIDER_URL, "remote://mymachine:4447");

                        p.put(Context.SECURITY_PRINCIPAL, "user");

                        p.put(Context.SECURITY_CREDENTIALS, "pwd");

                        try {

                           inCtx.close();

                           

                            inCtx = new InitialContext(p);

                            QueueConnectionFactory qcf = (QueueConnectionFactory) inCtx.lookup("jms/RemoteConnectionFactory");

                            Queue que = (Queue) inCtx.lookup("myQueue");

                            QueueConnection conn = qcf.createQueueConnection("user", "pwd");

                            session = conn.createQueueSession(false,

                                    QueueSession.AUTO_ACKNOWLEDGE);

                            sender = session.createSender(que);

                        } catch (Exception e) {

                            e.printStackTrace();

                        }

             

                    } catch (Exception e) {

                        e.printStackTrace();

                    }

                }

             

                public void run() {

                    try {

                        System.out.println("Clietn ID is:   " + sender.getDestination());

                        sleep(5000000);

                        sender.close();

                        session.close();

                    } catch (Exception e) {

                        e.printStackTrace();

                    }

                }

             

                public static void main(String[] args) throws NamingException {

                    Properties p = new Properties();

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

                    p.put(Context.PROVIDER_URL, "remote://mymachine:4447");

                    p.put(Context.SECURITY_PRINCIPAL, "user");

                    p.put(Context.SECURITY_CREDENTIALS, "pwd");

             

                    final InitialContext iniCtx = new InitialContext(p);

             

                    for (;;) {

                        (new JMSTest(iniCtx)).start();

                    }

                }

            }

             

            JARs I have in class path are:

             

            jboss-as-controller-7.1.1.Final.jar

            jboss-as-controller-client-7.1.1.Final.jar

            jboss-as-protocol-7.1.1.Final.jar

            jboss-dmr-1.1.1.Final.jar

            .jboss-logging-3.1.0.GA.jar

            jboss-logmanager-1.2.2.GA.jar

            jboss-marshalling-1.3.11.GA.jar

            jboss-remoting-3.2.3.GA.jar

            jboss-sasl-1.0.0.Final.jar

            jboss-threads-2.0.0.GA.jar

            xnio-api-3.0.3.GA.jar

            xnio-nio-3.0.3.GA.jar

            jboss-client.jar

             

            Any input would be appreciated.

             

            Thanks for your time and help.

            • 3. Re: Initial context create issue
              thinksteep

              Hi Community,

               

              Could someone help me on this? I am really stuck.

               

              Thanks for your time!

               

              Thank you,

              • 4. Re: Initial context create issue
                ctomc

                can you try to reproduce this with latest nightly builds?

                 

                 

                 

                --

                tomaz

                • 5. Re: Initial context create issue
                  thinksteep

                  Hi Tomaz cerar,

                   

                  Thanks for your reply!

                   

                  http://hudson.jboss.org/hudson/view/AS7/job/as7-master-build/

                   

                  Is this the place from where I can get nightly builds?

                   

                  Thanks for your time and help.

                  • 6. Re: Initial context create issue
                    jaikiran

                    thinksteep thinksteep wrote:

                     

                     

                    Is this the place from where I can get nightly builds?

                     

                     

                    https://community.jboss.org/thread/167590