cancel
Showing results for 
Search instead for 
Did you mean: 

JMS

Former Member
0 Kudos

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;

}

}

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Peter,

Some other person had the same problem(). I manage to put the message to the same queue if I do it from JSP running on the SAP WS. The same conde will succesfully get the initialcontext, ConnectionFactory, Queue but would throw the exception I mentioned before at the time of creating the connection.

Any help would be appriciated,

Thanks,

Former Member
0 Kudos

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

Answers (5)

Answers (5)

Former Member
0 Kudos

Peter,

That is it. The dispatcher section which had 50010 port configured. Every time I start the sap I have to restart going from VA. But once I thought it would come up by itself. That was throwing me off.

Thanks again, for making me think again. I am OK now but it would be nice if it starts by itself each time I start the SAP

Former Member
0 Kudos

Peter,

Any sample for standalone java client. Also as I asked do I need to do anything in the configuration in VI.

Thanks,

Former Member
0 Kudos

Peter, Thanks for your input on this. Please continue to give me your thoughts.

Yes I am trying all angle. I have tried from standalone client and I also have a jsp which does exact same thing.

I want to accomplish both. If you have whole sample for both and please pass it along, I would really appriciate. I am almost there. Also I have downloaded evaluation version last week(SAPNetWeaver04SneakPreviewSlimSP11[1].zip) and that is the one I am using. I am relativley new to this. I am almost there. I have alreday estabilished the connectivity from SAP to BEA WebLogic JMS using EJB and invoking the ConnectionFactory on BEA WebLogic and putting the message on the Queue of WebLogi So if I can get the standlone client running for SAP, I am hoping I can create EJB on BEA WebLogic and put the same logic and estabilish BEA to SAP.

I know SAP just line BEA provides JMS Connector but I ran into following problem, so I am taking EJB Route.

I tried the JMS Connector after putting required BEA Library thory Library Service. It reconginse the library but when it looks for the Connection Factory on BEA WebLogic, although it is instanceof javax.jms.QueueConnectionFactory, it sends me that it is wrong class. So I am taking the approch of handcode EJB

Former Member
0 Kudos

Hi Matthew,

If you are new and you are looking for JMS sample, you may wish to try the default MDB "Hello world" sample written in JMS that comes with the server.

Just try :

http://<your host>:<your HTTP port>/examples/mdb/mdb.html

HTH

Peter

Former Member
0 Kudos

Peter,

Thanks,

I have successful lookup to ConnectionFactory and Queue.

As the looked object is not null. I alos restarted the server. In the server.0.log I see following, which indicates the object does not exists. But how come I get successful lookup. Do I need to do anything once I setup ConnectionFactory and Queue in Visual Administrator. As I have the aloways_start option on my JMS instance under JMS Provider.

#1.5#000F1F1F8D67004B000000010000069C00041085044F2781#1144063395818#/System/Serv

er#sap.com/testEAR#com.sap.engine.services.jndi#Administrator#71####3e872260c304

11daa378000f1f1f8d67#SAPEngine_Application_Thread[impl:3]_38##0#0#Info#1#com.sap

.engine.services.jndi#Plain###Path to object does not exist at jmsfactory, the w

hole lookup name is webContainer/applications/sap.com/testEAR/contextRoot/jmsfac

tory/JMS1/SAP_CF1.#

#1.5#000F1F1F8D67004B000000020000069C00041085044F5A6C#1144063395828#/System/Serv

er#sap.com/testEAR#com.sap.engine.services.jndi#Administrator#71####3e872260c304

11daa378000f1f1f8d67#SAPEngine_Application_Thread[impl:3]_38##0#0#Info#1#com.sap

.engine.services.jndi#Plain###Path to object does not exist at jmsqueues, the wh

ole lookup name is webContainer/applications/sap.com/testEAR/contextRoot/jmsqueu

es/JMS1/SAP_Q1.#

Former Member
0 Kudos

Hi Matthew,

Looking at these log statements it seems that you are trying to use the JMS not from standalone client as you have said, but from inside a servlet/JSP that resides on the server

and is deployed in "testEAR".

If you want to use the JMS resources from a web application, you should describe them in files jms-destinations.xml and jms-factories.xml and package those into your EAR.

Btw, you are using a server with Netweaver 2004 or Netweaver 2004s, right ?

Best Regards

Peter

Former Member
0 Kudos

Hi Matthew,

looking at the exception it seems that your connection factory was not completely initialized when looked up from the naming. I would suggest looking at the server trace files for some exceptions and warnings and then rebooting the whole server.

HTH

Peter