2 Replies Latest reply on May 7, 2005 12:33 AM by minmay

    JNDI via a JDK 1.2 client - is JBoss JDK 1.4 dependent?

    minmay

      Hello folks,

      My JBoss AS is running on JDK 1.4
      I configured a JMS topic.

      I have a Dynix JDK 1.2 client that needs to send messages to the app server.

      I have the following jars in my client's classpath [set as Manfiest classpath attribute value pairs]:
      concurrent.jar
      javax.jms.jar (downloaded from Sun)
      jboss-common-client.jar
      jboss-system-client.jar
      jbossmq-client.jar
      jndi.jar (version 1.1.2) downloaded from Sun
      jnp-client.jar
      log4j-1.2.9.jar

      This is the output I get:

      Exception in thread "main"
      java.lang.NoClassDefFoundError: java/net/SocketAddress
      at
      org.jnp.interfaces.NamingContextFactory.getInitialContext(NamingContextFactory.java:40)
      at
      javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:771)
      at
      javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:169)
      at
      javax.naming.InitialContext.(InitialContext.java:146)
      at
      infonet.jms.PublisherCommand.execute(PublisherCommand.java,CompiledCode)
      at
      infonet.jms.PublisherCommand.main(PublisherCommand.java:143)

      Does this mean, heaven's forbid, that JBoss clients, such as my legacy dynix system that wants to send a JMS message through it's 1.2 JDK can not do so, are required to be JDK 1.4 and above?

      Below is my class file that sent the JMS messages:

      package infonet.jms;
      
      import javax.jms.JMSException;
      import javax.jms.Topic;
      import javax.jms.TopicConnection;
      import javax.jms.TopicConnectionFactory;
      import javax.jms.TopicPublisher;
      import javax.jms.TopicSession;
      import javax.jms.TextMessage;
      import javax.naming.InitialContext;
      import javax.naming.NamingException;
      import javax.naming.Context;
      import java.util.Hashtable;
      
      
      /**
       * Publishes a text message to the given topic.
       */
      public class PublisherCommand
      {
       /** The initial context factory */
       private String ctxFactory = null;
       /** The provider url */
       private String providerUrl = null;
       /** topic JNDI Name */
       private String topicJndiName = null;
       /** The message text */
       private String text = null;
       /**
       * Retrieves the initial context factory
       * @return the initial context factory
       */
       public String getCtxFactory()
       {
       return ctxFactory;
       }
       /**
       * Sets the initial context factory
       * @param ctxFactory the initial context factory.
       */
       public void setCtxFactory(String ctxFactory)
       {
       this.ctxFactory = ctxFactory;
       }
       /**
       * Retrieves the provider url.
       * @return the provider url.
       */
       public String getProviderUrl()
       {
       return providerUrl;
       }
       /**
       * Sets the provider url.
       * @param providerUrl The provider url.
       */
       public void setProviderUrl(String providerUrl)
       {
       this.providerUrl = providerUrl;
       }
      
       /**
       * Retrieves the message text that will be sent.
       * @return the message.
       */
       public String getText()
       {
       return text;
       }
       /**
       * Sets the message to that will be sent.
       * @param text The message text to send.
       */
       public void setText(String text)
       {
       this.text = text;
       }
       /**
       * Retrieves the topic JNDI name.
       * @return the topic JNDI name.
       */
       public String getTopicJndiName()
       {
       return topicJndiName;
       }
       /**
       * Sets the topic JNDI name.
       * @param topicJndiName the topic JNDI name.
       */
       public void setTopicJndiName(String topicJndiName)
       {
       this.topicJndiName = topicJndiName;
       }
      
       /**
       * Publishes the text message to a topic.
       */
       public void execute() throws JMSException,NamingException
       {
       if (topicJndiName==null || text==null || ctxFactory==null || providerUrl==null)
       throw new IllegalArgumentException("topic, text, ctxFactory, and providerUrl must be set");
      
       TopicConnection con = null;
       try
       {
       Hashtable env = new Hashtable();
       env.put(Context.INITIAL_CONTEXT_FACTORY,ctxFactory);
       env.put(Context.PROVIDER_URL,providerUrl);
       InitialContext ctx = new InitialContext(env);
       TopicConnectionFactory tcf = (TopicConnectionFactory) ctx.lookup("ConnectionFactory");
       con = tcf.createTopicConnection();
       Topic topic = (Topic) ctx.lookup(topicJndiName);
       TopicSession session = con.createTopicSession(false,TopicSession.AUTO_ACKNOWLEDGE);
       con.start();
       TopicPublisher publisher = session.createPublisher(topic);
       TextMessage message = session.createTextMessage(text);
       publisher.publish(message);
       }
       finally
       {
       if (con!=null)
       con.close();
       }
       }
      
       /**
       * Runs this command for test purposes
       * @param args none requred.
       * @throws Exception
       */
       public static void main(String args[]) throws Exception
       {
       System.out.println("Begin Publsher Command, now=" + System.currentTimeMillis());
      
       PublisherCommand publisher = new PublisherCommand();
       publisher.setTopicJndiName("topic/tmipMQ");
       publisher.setCtxFactory("org.jnp.interfaces.NamingContextFactory");
       publisher.setProviderUrl("jnp://204.79.138.126:1099");
       publisher.setText("A text msg, now=" + System.currentTimeMillis());
      
       try
       {
       publisher.execute();
       }
       catch (JMSException e)
       {
       e.printStackTrace();
       }
       catch (NamingException e)
       {
       e.printStackTrace();
       }
      
       System.out.println("End Publisher Command");
       System.exit(0);
       }
      }
      
      


      Thank you, any help is appreciated.

        • 1. Re: JNDI via a JDK 1.2 client - is JBoss JDK 1.4 dependent?
          starksm64

          JDK1.2 has not been supported for nearly 3 years.

          • 2. Re: JNDI via a JDK 1.2 client - is JBoss JDK 1.4 dependent?
            minmay

            Hello Mr. John Stark,

            We actually met before, at LAJUG. I hope to see you there again. In fact, I tried to reach JBoss and invite them again, but I was not responded back to.

            Thank you for informing me that JDK 1.2 hasn't been supported for 3 years.

            To me, it makes perfect sense that JBoss AS requires a modern JDK.
            But it really would be nice if legacy systems could communicate to the JBoss AS as clients. I was so close to integrating a JDK 1.2 JMS solution from Dynix. Fortunately, JMS 1.2 is compatible even on JDK 1.1 systems, which lend it very well to legacy systems. JMS also plays a role in the pivitol SOA. I think that the only aspect of JBoss that prevented this legacy integration was JNP's dependence on JDK 1.4 libraries. I perfectly understand the need for core of JBoss to be dependent on a modern JDK, but the ability for a client to connect with an older JDK and utilize a JDK 1.1-1.3 compatible API is quite persuasive.

            Regardless, I am very thankful for the excellent work that JBoss has provided to the community.

            I guess my best alternative is to use Client/Server sockets, or an HTTP post for this JMS message.