I have a MDB running in WebSphere, when it tries to pull a message off an MQ Queue the following exception is thrown:
com.ibm.mq.MQException: Message catalog not found
Any idea how to resolve this?
I have a MDB running in WebSphere, when it tries to pull a message off an MQ Queue the following exception is thrown:
com.ibm.mq.MQException: Message catalog not found
Any idea how to resolve this?
Google says it's a missed entry in the classpath: http://www.mqseries.net/phpBB2/viewtopic.php?t=5979&highlight=mqji
Add the directory containing the mqji.properties file to the CLASSPATH
It turns out that this error was thrown because I had the Queue Connection Factory defined at server level (on the WebSphere v6 server) and the wrong classloader was being used to load the above mentioned properties file.
I solved the issue by redefining factory at cell level.
Since the error message you'll be getting with the message catalog is pretty useless, too, here is a little patch for the mq.jar:
Add this code to MQException:
// PATCH New fields
private final static IntHashMap completionCodes = new IntHashMap ();
private final static IntHashMap reasonCodes = new IntHashMap ();
static
{
addCodes (completionCodes, "MQCC_");
addCodes (reasonCodes, "MQRC_");
}
/**
* PATCH Create a map of names for the MQ error codes
*
* @param map
* @param prefix
*/
private static void addCodes(IntHashMap map, String prefix)
{
Field[] field = MQException.class.getFields();
try
{
for (int i = 0; i < field.length; i++)
{
String name = field[i].getName();
if (name.startsWith(prefix))
{
name = name.substring(prefix.length());
int value = field[i].getInt(null);
map.put (value, name);
}
}
}
catch (IllegalArgumentException e) {
throw new RuntimeException (e);
}
catch (IllegalAccessException e) {
throw new RuntimeException (e);
}
}
Replace getMessage()
with this code:
// PATCH Complete rewrite
public String getMessage()
{
if(ostrMessage == null) {
String rc = (String)reasonCodes.get(reasonCode);
if (rc == null)
rc = "ReasonCode "+reasonCode;
String cc = (String)completionCodes.get(completionCode);
if (cc == null)
cc = "CompletionCode "+completionCode;
String message = "MQJE001: "+cc+" "+rc;
if(msgId == 0)
ostrMessage = message;
else {
String s = msgId+" {0} {1}";
if (exceptionMessages != null) {
s = exceptionMessages.getString(Integer.toString(msgId));
}
if(numInserts > 0) {
Object as1[] = new String[numInserts];
if(numInserts > 0) as1[0] = insert1;
if(numInserts > 1) as1[1] = insert2;
s = MessageFormat.format(s, as1);
}
ostrMessage = message+"\n"+s;
}
if (underlyingException != null)
ostrMessage = ostrMessage + "\n" + underlyingException.getMessage();
}
return ostrMessage;
}
Either compile these two classes into a new jar or patch the original mq.jar.
Instead of the MQJE001: RC 2 CC 2035, you'll get "MQJE001: FAILED NOT_AUTHORIZED"