problem in sending message to websphere mq from java service

i have written java service to send message to websphere mq.but its giving exception while creating JmsFactoryFactory.getInstance(WMQConstants.WMQ_PROVIDER).the same code is running fine when am running it outside webmethod(independently on eclipse). can anyone help me here.

Could you post the whole code? My blind guess is that an import of a jar might be missing.

Cheers,
Akshith

jms.jar and com.ibm.mqjms.jar are included

public static final void publishMessageToDestinationQueue (IData pipeline)
        throws ServiceException
    {
        // --- <<IS-START(publishMessageToDestinationQueue)>> ---
        // @subtype unknown
        // @sigtype java 3.5
        boolean bMessageStatus = true;
                Connection connection = null;
                Session session = null;
                Destination destinationQueue = null; 
                MessageProducer producer = null;
                 final JmsFactoryFactory f = null;      
              
                String host = (String) ValuesEmulator.get(pipeline, "host");
                String port = (String) ValuesEmulator.get(pipeline, "port");
                String queueManagerName = (String) ValuesEmulator.get(pipeline, "queueManagerName");
                String destinationQueueName = (String) ValuesEmulator.get(pipeline, "destinationQueueName");
                String channel = (String) ValuesEmulator.get(pipeline, "channel");
                
                        logWarnMsg("gxs.swift.websphereMQ:sendMessageToRemoteQueue","!");
                        try {
                            final JmsFactoryFactory ff = JmsFactoryFactory.getInstance(WMQConstants.WMQ_PROVIDER);
                        logWarnMsg("gxs.swift.websphereMQ:sendMessageToRemoteQueue","!!");
                            final JmsConnectionFactory cf = ff.createConnectionFactory();
                        logWarnMsg("gxs.swift.websphereMQ:sendMessageToRemoteQueue","!!!");
                            cf.setStringProperty(WMQConstants.WMQ_HOST_NAME, "10.24.199.37");
                            cf.setIntProperty(WMQConstants.WMQ_PORT, 1419);
                            cf.setStringProperty(WMQConstants.WMQ_QUEUE_MANAGER, "QM_SMG");
                            cf.setStringProperty(WMQConstants.WMQ_CHANNEL, "CLIENT.QM_SMG");//CLIENT.QM_SMG
                            cf.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE, WMQConstants.WMQ_CM_CLIENT);// Uncomment when you are running the application from Client machine
                                  
                            connection = cf.createConnection();
                            if(connection == null)
                            {
                                logWarnMsg("gxs.swift.websphereMQ:sendMessageToRemoteQueue","Error in creating JMS connection to WMQ_PROVIDER");
                                //return false;
                                ValuesEmulator.put(pipeline, "bMessageStatus", "false");        
                            }
                            
                            session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);             
                            destinationQueue = session.createQueue("local");              
                            producer = session.createProducer(destinationQueue);
                            
                            final TextMessage message = session.createTextMessage
                            ("Message sent to the remote queue");
                            
                            connection.start();
                            
                            producer.send(message);              
                        }
                        catch (JMSException jmsexception) {
                            bMessageStatus = false;
                        ValuesEmulator.put(pipeline, "bMessageStatus", "false");
                        jmsexception.printStackTrace();
                            logWarnMsg("gxs.swift.websphereMQ:sendMessageToRemoteQueue","JMSException!!: "+jmsexception.getMessage());
                        }
                        finally {
                          if (producer != null) {
                            try {
                              producer.close();
                            }
                            catch (JMSException jmsexception) {
                                logWarnMsg("gxs.swift.websphereMQ:sendMessageToRemoteQueue","JMSException: "+jmsexception.getMessage());
                            }
                          }
                 
                          if (session != null) {
                            try {
                              session.close();
                            }
                            catch (JMSException jmsexception) {
                                logWarnMsg("gxs.swift.websphereMQ:sendMessageToRemoteQueue","JMSException: "+jmsexception.getMessage());
                            }
                          }
                
                          if (connection != null) {
                            try {
                              connection.close();
                            }
                            catch (JMSException jmsexception) {
                                logWarnMsg("gxs.swift.websphereMQ:sendMessageToRemoteQueue","JMSException: "+jmsexception.getMessage());
                            }
                          }
                        }
                ValuesEmulator.put(pipeline, "bMessageStatus", bMessageStatus);
        // --- <<IS-END>> ---


                
    }

Why is this being done using Java code and not the JMS adapter?

As Rob mentioned above, you could use the services under pub.jms in WmPublic package for accomplishing the same.

Also looks like the JmsFactoryFactory is not part of either jars you mentioned above. What do you have under the imports section?

Cheers,
Akshith

JmsFactoryFactory is part of [COLOR=#000000][FONT=verdana]com.ibm.mqjms.
imports related to Jms are:

[/font][/color]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 com.ibm.msg.client.jms.JmsConnectionFactory;
import com.ibm.msg.client.jms.JmsFactoryFactory;

[COLOR=#000000][FONT=verdana]

[/font][/color]

The code looks fine and the imports are right, not sure what could be wrong here. What exception are you getting? Could you use the pub.jms services to accomplish this task?

Cheers,
Akshith

Why is this being done using Java code and not the JMS adapter?