ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » MQ Client using Java

Post new topic  Reply to topic
 MQ Client using Java « View previous topic :: View next topic » 
Author Message
sjagarla
PostPosted: Wed Apr 24, 2002 11:04 am    Post subject: Reply with quote

Newbie

Joined: 23 Apr 2002
Posts: 1

Hello Everybody,

I am very new to MQ Series and would like to test my MQ Server ( Remote)connection through Java Client. Here is my sample code.

// MQSeries classes for Java sample application
import com.ibm.mq.*; // Include the MQSeries classes for Java package
import java.util.Hashtable; // Required for properties

public class MQSample
{
private String hostname = "hub-tm1"; // Remote host
private String qManager = "MQBKRT1.QM1"; // queue name
private String channel = "CHANNEL.JAVA"; // Channel name

private MQQueueManager qMgr;

public static void main(String args[]) {
new MQSample();
}

public MQSample() {

MQEnvironment.hostname = hostname;
MQEnvironment.channel = channel;
MQEnvironment.properties.put(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES);

try {

java.util.Hashtable properties;

qMgr = new MQQueueManager(qManager);

int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT ;

MQQueue system_default_local_queue =
qMgr.accessQueue("SYSTEM.DEFAULT.LOCAL.QUEUE", openOptions );

MQMessage hello_world = new MQMessage();
hello_world.writeUTF("Hello World!");

MQPutMessageOptions pmo = new MQPutMessageOptions(); // accept the // defaults,
// same as MQPMO_DEFAULT
system_default_local_queue.put(hello_world,pmo);

MQMessage retrievedMessage = new MQMessage();
retrievedMessage.messageId = hello_world.messageId;

MQGetMessageOptions gmo = new MQGetMessageOptions(); // accept the defaults
// same as MQGMO_DEFAULT
system_default_local_queue.get(retrievedMessage, gmo);

String msgText = retrievedMessage.readUTF();
System.out.println("The message is: " + msgText);
system_default_local_queue.close();
qMgr.disconnect();
}
catch (MQException ex)
{
System.out.println("An MQSeries error occurred : Completion code " +
ex.completionCode + " Reason code " + ex.reasonCode);
}
catch (java.io.IOException ex)
{
System.out.println("An error occurred whilst writing to the message buffer: " + ex);
}
}
} // end of sample


I run the java class through bat file and getting the following errors.

E:MQmqmjavalibcode>call java -classpath "E:jdk1.3lib;E:Mqmqmjavalibc
om.ibm.mq.jar;." MQSample
Exception in thread "main" java.lang.NoClassDefFoundError: javax/transaction/xa/
XAException
at com.ibm.mq.MQSESSIONServer.getMQSESSION(MQSESSIONServer.java:67)
at com.ibm.mq.MQSESSION.getSession(MQSESSION.java:241)
at com.ibm.mq.MQManagedConnectionJ11.<init>(MQManagedConnectionJ11.java:
148)
at com.ibm.mq.MQBindingsManagedConnectionFactoryJ11._createManagedConnec
tion(MQBindingsManagedConnectionFactoryJ11.java:136)
at com.ibm.mq.MQBindingsManagedConnectionFactoryJ11.createManagedConnect
ion(MQBindingsManagedConnectionFactoryJ11.java:154)
at com.ibm.mq.StoredManagedConnection.<init>(StoredManagedConnection.jav
a:80)
at com.ibm.mq.MQSimpleConnectionManager.allocateConnection(MQSimpleConne
ctionManager.java:150)
at com.ibm.mq.MQQueueManager.obtainBaseMQQueueManager(MQQueueManager.jav
a:649)
at com.ibm.mq.MQQueueManager.construct(MQQueueManager.java:598)
at com.ibm.mq.MQQueueManager.<init>(MQQueueManager.java:375)
at MQSample.<init>(MQSample.java:37)
at MQSample.main(MQSample.java:23)

I appreciate your help/suggestions in regards to fix these errors

Regards
Sreeni
ERRORS :


[ This Message was edited by: sjagarla on 2002-04-24 12:05 ]
Back to top
View user's profile Send private message
gowrisha
PostPosted: Wed Apr 24, 2002 11:17 am    Post subject: Reply with quote

Newbie

Joined: 23 Apr 2002
Posts: 2

did you include jta.jar file in your classpath? it is part of the java library for MQSeries.
Back to top
View user's profile Send private message
deneb
PostPosted: Fri Apr 26, 2002 4:45 pm    Post subject: Reply with quote

Novice

Joined: 15 Apr 2002
Posts: 18

hi

Actually there is nothing in the code that mentions the need of JTA and XA Co-ordinators. So why should there be any need of jta in the classpath ???

deneb
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » MQ Client using Java
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.