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 » General IBM MQ Support » Problem with MQ Client connection using MQSERVER or TAB file

Post new topic  Reply to topic
 Problem with MQ Client connection using MQSERVER or TAB file « View previous topic :: View next topic » 
Author Message
hilltops
PostPosted: Thu Jun 07, 2007 6:48 am    Post subject: Problem with MQ Client connection using MQSERVER or TAB file Reply with quote

Centurion

Joined: 01 Mar 2006
Posts: 112

I am having difficulties connecting to a queue manager from a client server using a java application. I get error code 2058 (MQRC_Q_MGR_NAME_ERROR) I have tried 2 approaches;

1) Using the environment variable MQSERVER option

MQSERVER is set as follows;

export MQSERVER=CHG.CONN/TCP/'myhostname(myportno)'

And defined the server conn as follows;

DEFINE CHANNEL(CHG.CONN) CHLTYPE(SVRCONN) +
TRPTYPE(TCP) +
REPLACE


2) Using channel definition table


I have defined a server/cleint connection channels on my queue manager MYQMGR as follows

DEFINE CHANNEL(CHG.CONN) CHLTYPE(CLNTCONN) +
TRPTYPE(TCP) +
CONNAME('myhostname(myportno)') +
REPLACE


DEFINE CHANNEL(CHG.CONN) CHLTYPE(SVRCONN) +
TRPTYPE(TCP) +
REPLACE

and copied the AMQCLCHL.TAB file to a location (/home/johnny) on the client machine. I have set the env variables as follows

export MQCHLLIB=/home/johnny
export MQCHLTAB=AMQCLCHL.TAB


In both cases I have got a listener running and am using MQ 6. My test java application looks like this;


import com.ibm.mq.*;
import java.net.*;

public class TCPPutSample2 {
public static void main(String args[]) {
try{
MQQueueManager qmgr = new MQQueueManager("MYQMGR");
int openOption = MQC.MQOO_OUTPUT;
MQQueue q = qmgr.accessQueue("TEST", openOption);
MQMessage message = new MQMessage();
message.writeUTF("TTTTTTTTTTTTTTTTTTTTT");
MQPutMessageOptions pmo = new MQPutMessageOptions();
q.put(message, pmo);
q.close();
qmgr.disconnect();
System.out.println("Done!");
}
catch(Exception ex){
System.out.println("A WebSphere MQ Error occured : fix it please.................");
ex.printStackTrace();
}
}
}

I am not able to see where I have gone wrong. Can anyone spot the error please? In both cases I get the same erorr.

Thankx
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Jun 07, 2007 6:53 am    Post subject: Re: Problem with MQ Client connection using MQSERVER or TAB Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

hilltops wrote:
I am having difficulties connecting to a queue manager from a client server using a java application. I get error code 2058 (MQRC_Q_MGR_NAME_ERROR) I have tried 2 approaches;


The most blatant thing to check is that the queue manager is called MYQMGR not myqmgr or MyQmgr. If there was a problem with the client configuration I'd expect a 2059 rather than a 2058.

You might also want to include a QMNAME parameter in the CLNTCONN definition.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
hilltops
PostPosted: Thu Jun 07, 2007 7:01 am    Post subject: Reply with quote

Centurion

Joined: 01 Mar 2006
Posts: 112

This was the first thing I checked. My queue manager name is definitely the name passed into the constructor of the MQQueueManager object, as in

MQQueueManager qmgr = new MQQueueManager("MYQMGR");
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Jun 07, 2007 7:08 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

hilltops wrote:
This was the first thing I checked. My queue manager name is definitely the name passed into the constructor of the MQQueueManager object, as in

MQQueueManager qmgr = new MQQueueManager("MYQMGR");


I would have been surprised if you'd not checked that, but be certain the case is right (not been folded to lower case etc by some rogue tool).

Assuming that's all correct (as I suspect it is), port number is the next possible culprit. If you're getting 2058 then MQ can't find a qmgr called that where it's looking.

I also underline the advice to include an explict QMNAME in the table, or to leave the name blank in your code.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
hilltops
PostPosted: Thu Jun 07, 2007 7:17 am    Post subject: Reply with quote

Centurion

Joined: 01 Mar 2006
Posts: 112

When I use the following code, it does work. The difference is that with the code below I use the MQEnvironment class to build the connection;

import com.ibm.mq.*;
import java.net.*;

public class TCPPutSample {

public static void main(String args[]) {

MQEnvironment.hostname = "myhostname";
MQEnvironment.port = myportno;
MQEnvironment.channel = "CHG.CONN";

try{
MQQueueManager qmgr = new MQQueueManager("MYQMGR");
int openOption = MQC.MQOO_OUTPUT;
MQQueue q = qmgr.accessQueue("TEST", openOption);
MQMessage message = new MQMessage();
message.writeUTF("TTTTTTTTTTTTTTTTTTTTT");
MQPutMessageOptions pmo = new MQPutMessageOptions();
q.put(message, pmo);
q.close();
qmgr.disconnect();
System.out.println("Done!");
}
catch(Exception ex){
System.out.println("A WebSphere MQ Error occured : fix it please.................");
ex.printStackTrace();
}
}
}
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Jun 07, 2007 7:20 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

Then you need someone with better Java than me....
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Jun 07, 2007 7:48 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Java does not use MQSERVER or MQCHLLIB/MQCHLTAB.

You need to populate the MQEnvironment properties, as clearly outlined in the Using Java manual.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
hilltops
PostPosted: Thu Jun 07, 2007 8:22 am    Post subject: Reply with quote

Centurion

Joined: 01 Mar 2006
Posts: 112

Thankx. I thought as much, but unfortunately allowed myself to be swayed by some application developers.

When I modified the code, pointing to the channel table as shown below, it works swimingly;

try {
chldefurl = new URL(file:///home/johnny/AMQCLCHL.TAB);
}
catch(Exception e){
System.out.println("Malformed URL...Quiting");
System.exit(1);
}


try{
MQQueueManager qmgr = new MQQueueManager("", chldefurl);


Thankx
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Jun 07, 2007 2:47 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

jefflowrey wrote:
Java does not use MQSERVER or MQCHLLIB/MQCHLTAB.

You need to populate the MQEnvironment properties, as clearly outlined in the Using Java manual.


Since Version V6 you can specify the place (url in form of file:///xxxx) where the channel table is. You can now use the channel table with either java base or JMS.

Jeff is correct java does not use the MQSERVER variable.

Not unless you retrieve it, parse it and use the information obtained to specify your connection parameters either in MQEnvironment class or in your qcf.

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » General IBM MQ Support » Problem with MQ Client connection using MQSERVER or TAB file
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.