9 Replies Latest reply on May 23, 2002 4:08 AM by gmccreath

    Another newbie NS Question ...

    gmccreath Newbie


      Do I have to be running a java class 'inside' of JBoss to use the naming service? In other words, can I just run JBoss, and then in a separate window run my little Java classes to learn and test JBossNS? ... or do I have to be operating 'within' the Jboss framework ... ?

      Many thanks

      Greg.

        • 1. Re: Another newbie NS Question ...
          Chris Nagy Newbie

          Hi,

          I've been using JBoss 3.0 RC2 (with tomcat) and JacORB 1.4 beta4 to run my java CORBA servers and clients (in separate windows). To get it to work with JBoss, I had to:

          1. copy NS IOR found in the server.log into a separate file.
          2. Modify the jacorb.properties that come with JacORB 1.4 to point to that file for the 'ORBInitRef.NameService' property (and place the jacorb.properties into my home directory).

          After that, I was able to run my little java classes that registered to the JBoss NS.
          Is there any easier way to get the NS IOR (without looking at the server.log)?

          Thanks in advance,


          Chris Nagy

          • 2. Re: Another newbie NS Question ...
            Chris Nagy Newbie

            I think I might have misinterpreted your meaning of JBossNS. If you are talking about JNDI instead of Corba Naming Service then it is trivial to access the JNDI tree from outside the JBoss server.
            Remember to set the INITIAL_CONTEXT_FACTORY to 'org.jnp.interfaces.NamingContextFactory' and specify the correct host/port in the PROVIDER_URL.

            I've attached a small sample program to play around with. You'll need jboss.jar and jnpserver.jar in the classpath (they are found under the jboss lib directory).

            Hope this helps,


            Chris Nagy

            • 3. Re: Another newbie NS Question ...
              gmccreath Newbie

              Chris,

              Thankyou, it is JNDI I meant. You example program works and I will study it.

              So, if I'm using this with JBossMQ I would except the followig lines to work ...

              Hashtable env = new Hashtable();
              env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
              env.put(Context.PROVIDER_URL,"jnp://localhost:1099");
              Context ctx = new InitialContext(env);
              TopicConnectionFactory topicConnectionFactory;
              topicConnectionFactory = (TopicConnectionFactory) ctx.lookup("TopicConnectionFactory");

              But it falls over. Is the "TopicConnectionFactory" something I have to bind myself, or should it be there automagically?

              Many thanks.
              Greg.

              • 4. Re: Another newbie NS Question ...
                Chris Nagy Newbie

                Hi Greg,

                If you're using JBoss 3.0 then the TopicConnectionFactory has been renamed to : 'ConnectionFactory'

                so instead of :
                topicConnectionFactory = (TopicConnectionFactory) ctx.lookup("TopicConnectionFactory");
                it should be:
                topicConnectionFactory = (TopicConnectionFactory) ctx.lookup("ConnectionFactory");

                Hope that helps,


                Chris Nagy


                • 5. Re: Another newbie NS Question ...
                  gmccreath Newbie

                  Hi Chris,

                  Actually I using 2.2.4. It look like the proble is not the TopicConnectionFactory, but the name of the topic I'm trying to access. My jboss.jmcl tells me there is a topic called 'testTopic', but I get a

                  javax.naming.NameNotFoundException: testTopic not bound

                  exception when I try to :

                  Topic topic = (Topic) ctx.lookup("testTopic");

                  Am I missing something aout how JBoss names its topics, or binds them with the naming service ... or something ...

                  • 6. Re: Another newbie NS Question ...
                    Chris Nagy Newbie

                    Hi Greg,

                    Try using 'topic/testTopic' as per the JMS example:

                    http://www.jboss.org/online-manual/HTML/ch08s07.html#jms-jms-examples

                    It seems that JBoss places all the topics under a 'topic/' JNDI sub tree and all the queues under a 'queue/' JNDI sub tree.

                    Hope that helps,

                    Chris Nagy

                    • 7. Re: Another newbie NS Question ...
                      gmccreath Newbie

                      Thanks Chris,

                      That fixed that. Now I just have to get over the

                      org.jboss.mq.SpyJMSException: Cannot subscribe to this Destination:
                      javax.jms.JMSException; local class incompatible:

                      when trying to create a durable subscriber with

                      TopicSubscriber topicSubscriber = topicSession.createDurableSubscriber(topic, "john");

                      Geeez .... not having much luck am I.

                      Oh ... creating a non durable subscriber works .... The example in docs mentions very little about durable subscription apart from the requirement to have user in the jbossmq-state.xml file ("john" is in there).

                      • 8. Re: Another newbie NS Question ...
                        Chris Nagy Newbie

                        Hi Greg,

                        I think you might have a different version of the jboss classes in the client's classpath. That could be why you are getting the 'local class incompatible' exception. Can you post the full stack trace.

                        Also, I'm a little confused about why you used 'john' as the name of the durable subscriber. You have to specify the username/password when creating the TopicConnection from the TopicConnectionFactory (ie. "john"/"needle"). You can specify any name when you create the TopicSubscriber.

                        I made sure that all the *.jar files in the jboss/client directory were in my classpath before running a modified version of the "org\jboss\docs\jms\client\HelloSubscriber.java" found in the documentation examples ( http://www.jboss.org/doco_files/documentation-example.zip ).

                        I can post the modified example that worked for me under JBoss 2.4.4 with Tomcat, if you want.

                        Hope that helps,


                        Chris Nagy

                        • 9. Re: Another newbie NS Question ...
                          gmccreath Newbie


                          Thanks Chris,

                          I'll check the client classpaths. I've only got one installation of JBoss though ... (but I haven't added all the client jars - just the ones I thought I needed)

                          The "john" used to be "x", but I changed it to be a configured user in the jbossmq-state.xml file. Made no change though.

                          Thanks again. I'll let you know how I get on.