I am trying to write a java client which posts a message to a Queue.I am using Java 7 and RAD 8.5. RAD is complaining that some classes cannot be resolved.Please help me fix it.
import javax.jms.Connection;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.directory.InitialDirContext;
import com.ibm.msg.client.jms.JmsConnectionFactory;
import com.ibm.msg.client.jms.JmsDestination;
public class JMS_JNDI_Queue_Producer {
private static String initialContextUrl = "my url";
private static String connectionFactoryFromJndi = "my connection factory";
private static String destinationFromJndi = "my destination";
public static void main(String[] args) {
// Variables
Connection connection = null;
Session session = null;
Destination destination = null;
MessageProducer producer = null;
try {
String contextFactory = "com.sun.jndi.ldap.LdapCtxFactory";
Hashtable<String, String> environment = new Hashtable<String, String>();
environment.put(Context.INITIAL_CONTEXT_FACTORY, contextFactory);
environment.put(Context.PROVIDER_URL, initialContextUrl);
Context context = new InitialDirContext(environment);
System.out.println("Initial context found!");
// Lookup the connection factory
JmsConnectionFactory cf = (JmsConnectionFactory) context.lookup(connectionFactoryFromJndi);
// Lookup the destination
destination = (JmsDestination) context.lookup(destinationFromJndi);
// Create JMS objects
connection = cf.createConnection("mqclient","busclient");
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
producer = session.createProducer(destination);
// Create a message
long uniqueNumber = System.currentTimeMillis() % 1000;
TextMessage message = session.createTextMessage("JmsProducer: Your lucky number today is "
+ uniqueNumber);
connection.start();
System.out.println("JMS client connection started!");
producer.send(message);
System.out.println("Sent message:\n" + message);
producer.close();
System.out.println("Producer closed.");
session.close();
System.out.println("Session closed.");
connection.close();
System.out.println("JMS client connection closed.");
} catch (JMSException ex) {
ex.printStackTrace();
} catch (NamingException ne) {
ne.printStackTrace();
} catch (Exception ex){
ex.printStackTrace();
}
}
}
So RAD is complaining that it cannot find classes com.ibm.msg.client.jms.JmsConnectionFactory and com.ibm.msg.client.jms.JmsDestination.
I tried adding websphere 7 runtime and also a few jars that i read in other forums. Nothing is happening
Any ideas please