Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

JMS

I am trying to run JMS Client and I am getting this exception. I am relatively new but. I made sure through Visula Administrator that my Connection Factories and Queues are there

javax.jms.JMSException: The following hosts (hostname:port) cannot be accessed:

. Check host names and ports.

at com.sap.jms.client.connection.ConnectionFactory.getSocket(ConnectionF

actory.java:447)

at com.sap.jms.client.connection.ConnectionFactory.createConnection(Conn

ectionFactory.java:300)

at com.sap.jms.client.connection.ConnectionFactory.createConnection(Conn

ectionFactory.java:244)

at com.sap.jms.client.connection.QueueConnectionFactory.createQueueConne

ction(QueueConnectionFactory.java:70)

at QueueSend.main(QueueSend.java:43)

Here is the code: Look that the lookup for Queue and Connection Factory was successfull. I am writting standalone java client.

import java.util.Properties;

import javax.naming.*;

import java.io.*;

import javax.jms.*;

public class QueueSend {

public String uid = null;

public String pass = null;

public QueueSend(String u, String pas) {

this.uid = u;

this.pass = pas;

}

public static void main (String argv[]) {

System.out.println("MAIN EXECUTING");

Object o = null;

javax.naming.Context ctx = null;

QueueConnectionFactory queueConnectionFactory = null;

QueueConnection queueConnection = null;

QueueSession queueSession = null;

Queue queue = null;

QueueSender queueSender = null;

TextMessage message = null;

try {

System.out.println("IN TRY");

Properties properties = new Properties();

properties.put(Context.INITIAL_CONTEXT_FACTORY,

"com.sap.engine.services.jndi.InitialContextFactoryImpl");

properties.put(Context.SECURITY_PRINCIPAL,

"Administrator");

properties.put(Context.SECURITY_CREDENTIALS, "aBcD1234");

properties.put(Context.PROVIDER_URL, "SAMIN02.amer.bea.com:50004");

System.out.println("ABOUT TO GET CONTEXT");

ctx = new InitialContext(properties);

System.out.println("THE CONTEXT="+ctx);

queueConnectionFactory = (QueueConnectionFactory)ctx.lookup("jmsfactory/default/QueueConnectionFactory");

queue = (Queue) ctx.lookup("jmsqueues/JMS1/SAP_Q1");

queueConnection =

queueConnectionFactory.createQueueConnection();

queueSession = queueConnection.createQueueSession(false,

Session.AUTO_ACKNOWLEDGE);

queueSender = queueSession.createSender(queue);

message = queueSession.createTextMessage();

message.setText("DATA");

System.out.println("About to Send Message");

queueSender.send(message);

System.out.println("Just Send Message");

} catch (Exception e) { e.printStackTrace(); }

}

private static final boolean sap = false;

/*

  • Create a JNDI InitialContext object

*/

public static Context getContext() {

Context jndiContext = null;

try {

Properties properties = new Properties();

properties.put(Context.PROVIDER_URL, "SAMIN02.amer.bea.com:50004");

properties.put(Context.INITIAL_CONTEXT_FACTORY,

"com.sap.engine.services.jndi.InitialContextFactoryImpl");

properties.put(Context.SECURITY_PRINCIPAL,

"Administrator");

properties.put(Context.SECURITY_CREDENTIALS, "aBcD1234");

jndiContext = new InitialContext(properties);

return (jndiContext);

} catch (NamingException e) {

System.out.println("Could not create JNDI API " +

"context: " + e.toString());

System.exit(1);

}

return jndiContext;

}

}

replied

Hi Matthew,

When you make a standalone java client the connection will be performed by a TCP socket to the server. Your problem is this cannot be achieved. When you do it from JSP your code will interact directly with the JMS on the server. No opening of socket to itself. That's why it works.

I would suggest launching a visual administrator, then going to the "dispatcher" nodes, (not server) and checking the properties of the JMS_provider service. Set up there a valid TCP port (perhaps it is empty or it is not read ?), then try to restart the whole cluster.

If that will not help you, please open a OSS message where the SAP supoprt guys can help you.

HTH

Peter

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question