Forum Stats

  • 3,752,275 Users
  • 2,250,483 Discussions
  • 7,867,774 Comments

Discussions

Not able to connect-createQueueConnection jms

Hi ,

I am trying to send messages to my JMS server where I created a Connection & Queue.

But when I debug my code its getting the connection factory but getting failed at createQueueConnection() method,Any help is appreciated thatnks!!

Here is  my code

package com.abc.jms;

import java.io.BufferedReader;

import java.io.InputStreamReader;

import java.io.PrintStream;

import weblogic.utils.Debug;

import javax.jms.Queue;

import javax.jms.QueueConnection;

import javax.jms.QueueConnectionFactory;

import javax.jms.QueueSender;

import javax.jms.QueueSession;

import javax.jms.Session;

import javax.jms.TextMessage;

import javax.naming.*;

import java.util.Hashtable;

/**

* This client uses the remote HelloServer methods.

*

* @author Copyright (c) Oracle. All Rights Reserved.

*/

public class HelloClient {

  private final static boolean debug = true;

  /**

  * Defines the JNDI context factory.

  */

  public final static String JNDI_FACTORY = "weblogic.jndi.WLInitialContextFactory";

  public final static String JMS_FACTORY = "QCF";

  public final static String QUEUE = "TestQ";

  private static QueueConnectionFactory qconFactory;

  int port;

  String host;

  private static void usage() {

  System.err.println("Usage: java examples.rmi.hello.HelloClient " + "<hostname> <port number>");

  System.exit(-1);

  }

  public HelloClient() {

  }

  public static void main(String[] argv) throws Exception {

  if (argv.length < 2) {

  usage();

  }

  String host = argv[0];

  int port = 0;

  try {

  port = Integer.parseInt(argv[1]);

  } catch (NumberFormatException nfe) {

  usage();

  }

  try {

  InitialContext ic = getInitialContext("t3://" + host + ":" + port);

  // Hello obj = (Hello) ic.lookup("QCF");

  qconFactory = (QueueConnectionFactory) ic.lookup(JMS_FACTORY);

  System.out.println(

  "Successfully connected to HelloServer on " + host + " at port " + port + ": " + qconFactory);

  QueueConnection con = qconFactory.createQueueConnection();

  QueueSession ses = con.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);

  Queue t = (Queue) ic.lookup(QUEUE);

  QueueSender sender = ses.createSender(t);

  TextMessage msg = ses.createTextMessage();

  BufferedReader b = new BufferedReader(new InputStreamReader(System.in));

  while (true) {

  System.out.println("Enter Msg, end to terminate:");

  String s = b.readLine();

  if (s.equals("end"))

  break;

  msg.setText(s);

  // 7) send message

  sender.send(msg);

  System.out.println("Message successfully sent.");

  }

  } catch (Throwable t) {

  t.printStackTrace();

  System.exit(-1);

  }

  }

  private static InitialContext getInitialContext(String url) throws NamingException {

  Hashtable env = new Hashtable();

  env.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY);

  env.put(Context.PROVIDER_URL, url);

  return new InitialContext(env);

  }

}

Exception:

java.lang.StackOverflowError

  at weblogic.iiop.PortableRemoteObjectDelegateImpl.exportObject(PortableRemoteObjectDelegateImpl.java:15)

  at javax.rmi.PortableRemoteObject.exportObject(PortableRemoteObject.java:100)

  at weblogic.corba.client.naming.ReferenceHelperImpl.exportObject(ReferenceHelperImpl.java:58)

  at weblogic.rmi.extensions.PortableRemoteObject.exportObject(PortableRemoteObject.java:42)

  at weblogic.iiop.PortableRemoteObjectDelegateImpl.exportObject(PortableRemoteObjectDelegateImpl.java:15)

  at javax.rmi.PortableRemoteObject.exportObject(PortableRemoteObject.java:100)

  at weblogic.corba.client.naming.ReferenceHelperImpl.exportObject(ReferenceHelperImpl.java:58)

  at weblogic.rmi.extensions.PortableRemoteObject.exportObject(PortableRemoteObject.java:42)

  at weblogic.iiop.PortableRemoteObjectDelegateImpl.exportObject(PortableRemoteObjectDelegateImpl.java:15)

  at javax.rmi.PortableRemoteObject.exportObject(PortableRemoteObject.java:100)

  at weblogic.corba.client.naming.ReferenceHelperImpl.exportObject(ReferenceHelperImpl.java:58)

  at weblogic.rmi.extensions.PortableRemoteObject.exportObject(PortableRemoteObject.java:42)

  at weblogic.iiop.PortableRemoteObjectDelegateImpl.exportObject(PortableRemoteObjectDelegateImpl.java:15)

  at javax.rmi.PortableRemoteObject.exportObject(PortableRemoteObject.java:100)

  at weblogic.corba.client.naming.ReferenceHelperImpl.exportObject(ReferenceHelperImpl.java:58)

  at weblogic.rmi.extensions.PortableRemoteObject.exportObject(PortableRemoteObject.java:42)

  at weblogic.iiop.PortableRemoteObjectDelegateImpl.exportObject(PortableRemoteObjectDelegateImpl.java:15)

  at javax.rmi.PortableRemoteObject.exportObject(PortableRemoteObject.java:100)

  at weblogic.corba.client.naming.ReferenceHelperImpl.exportObject(ReferenceHelperImpl.java:58)

  at weblogic.rmi.extensions.PortableRemoteObject.exportObject(PortableRemoteObject.java:42)

  at weblogic.iiop.PortableRemoteObjectDelegateImpl.exportObject(PortableRemoteObjectDelegateImpl.java:15)

  at javax.rmi.PortableRemoteObject.exportObject(PortableRemoteObject.java:100)

  at weblogic.corba.client.naming.ReferenceHelperImpl.exportObject(ReferenceHelperImpl.java:58)

  at weblogic.rmi.extensions.PortableRemoteObject.exportObject(PortableRemoteObject.java:42)

  at weblogic.iiop.PortableRemoteObjectDelegateImpl.exportObject(PortableRemoteObjectDelegateImpl.java:15)

  at javax.rmi.PortableRemoteObject.exportObject(PortableRemoteObject.java:100)

  at weblogic.corba.client.naming.ReferenceHelperImpl.exportObject(ReferenceHelperImpl.java:58)

  at weblogic.rmi.extensions.PortableRemoteObject.exportObject(PortableRemoteObject.java:42)

  at weblogic.iiop.PortableRemoteObjectDelegateImpl.exportObject(PortableRemoteObjectDelegateImpl.java:15)

  at javax.rmi.PortableRemoteObject.exportObject(PortableRemoteObject.java:100)

  at weblogic.corba.client.naming.ReferenceHelperImpl.exportObject(ReferenceHelperImpl.java:58)

  at weblogic.rmi.extensions.PortableRemoteObject.exportObject(PortableRemoteObject.java:42)

  at weblogic.iiop.PortableRemoteObjectDelegateImpl.exportObject(PortableRemoteObjectDelegateImpl.java:15)

  at javax.rmi.PortableRemoteObject.exportObject(PortableRemoteObject.java:100)

  at weblogic.corba.client.naming.ReferenceHelperImpl.exportObject(ReferenceHelperImpl.java:58)

  at weblogic.rmi.extensions.PortableRemoteObject.exportObject(PortableRemoteObject.java:42)

  at weblogic.iiop.PortableRemoteObjectDelegateImpl.exportObject(PortableRemoteObjectDelegateImpl.java:15)

  at javax.rmi.PortableRemoteObject.exportObject(PortableRemoteObject.java:100)

  at weblogic.corba.client.naming.ReferenceHelperImpl.exportObject(ReferenceHelperImpl.java:58)

  at weblogic.rmi.extensions.PortableRemoteObject.exportObject(PortableRemoteObject.java:42)

  at weblogic.iiop.PortableRemoteObjectDelegateImpl.exportObject(PortableRemoteObjectDelegateImpl.java:15)

  at javax.rmi.PortableRemoteObject.exportObject(PortableRemoteObject.java:100)

  at weblogic.corba.client.naming.ReferenceHelperImpl.exportObject(ReferenceHelperImpl.java:58)

  at weblogic.rmi.extensions.PortableRemoteObject.exportObject(PortableRemoteObject.java:42)

  at weblogic.iiop.PortableRemoteObjectDelegateImpl.exportObject(PortableRemoteObjectDelegateImpl.java:15)

  at javax.rmi.PortableRemoteObject.exportObject(PortableRemoteObject.java:100)

  at weblogic.corba.client.naming.ReferenceHelperImpl.exportObject(ReferenceHelperImpl.java:58)

  at weblogic.rmi.extensions.PortableRemoteObject.exportObject(PortableRemoteObject.java:42)

  at weblogic.iiop.PortableRemoteObjectDelegateImpl.exportObject(PortableRemoteObjectDelegateImpl.java:15)

  at javax.rmi.PortableRemoteObject.exportObject(PortableRemoteObject.java:100)

  at weblogic.corba.client.naming.ReferenceHelperImpl.exportObject(ReferenceHelperImpl.java:58)

  at weblogic.rmi.extensions.PortableRemoteObject.exportObject(PortableRemoteObject.java:42)

  at weblogic.iiop.PortableRemoteObjectDelegateImpl.exportObject(PortableRemoteObjectDelegateImpl.java:15)

  at javax.rmi.PortableRemoteObject.exportObject(PortableRemoteObject.java:100)

This discussion has been closed.