“未找到消息目录”是什么意思?

时间:2008-10-14 13:47:02

标签: java websphere message-queue

当我尝试从MQ队列中提取消息时,我在WebSphere中运行了一个MDB 抛出以下异常:

com.ibm.mq.MQException:找不到消息目录

知道如何解决这个问题吗?

5 个答案:

答案 0 :(得分:2)

将包含 mqji.properties 文件的目录添加到CLASSPATH

答案 1 :(得分:0)

谷歌称这是一个错过了类路径的条目: http://www.mqseries.net/phpBB2/viewtopic.php?t=5979&highlight=mqji

答案 2 :(得分:0)

mqji.properties文件已包含在mq jar文件中。

消息目录未找到异常作为“MQJMS2002:无法从MQ队列获取消息”的一部分而被抛出。

答案 3 :(得分:0)

事实证明,抛出此错误是因为我已定义了队列连接工厂 在服务器级别(在WebSphere v6服务器上)并且正在使用错误的类加载器 加载上面提到的属性文件。

我通过在细胞层面重新定义工厂解决了这个问题。

答案 4 :(得分:0)

由于您将使用获取消息目录的错误消息也是无用的,这里有一个mq.jar的小补丁:

  1. 获取jad
  2. 反汇编MQException和MQInternalException(后者只是必需的,因为它继承自MQException;我们不会更改它。)
  3. 将此代码添加到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. 使用以下代码替换getMessage()

        // 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. 将这两个类编译成一个新的jar或修补原始的mq.jar。

  6. 取代MQJE001:RC 2 CC 2035,您将获得“MQJE001:FAILED NOT_AUTHORIZED”