views:

1329

answers:

5

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?

A: 

Google says it's a missed entry in the classpath: http://www.mqseries.net/phpBB2/viewtopic.php?t=5979&highlight=mqji

Vladimir Dyuzhev
+1  A: 

Add the directory containing the mqji.properties file to the CLASSPATH

olore
+1 correct answer
Romain Hippeau
A: 

The mqji.properties files is already included in the mq jar file.

The Message Catalog not found exception is thrown as part of a "MQJMS2002: failed to get message from MQ queue".

A: 

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.

A: 

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:

  1. Get jad
  2. Disassemble MQException and MQInternalException (the latter is only necessary because it inherits from MQException; we won't change it).
  3. 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);
     }
    }
    
  4. 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;
    }
    
  5. 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"

Aaron Digulla