【问题标题】:What does "Message Catalog Not Found" mean?“未找到消息目录”是什么意思?
【发布时间】:2010-09-17 02:29:08
【问题描述】:

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

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

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

【问题讨论】:

    标签: java websphere message-queue


    【解决方案1】:

    Google 说这是类路径中的一个缺失条目: http://www.mqseries.net/phpBB2/viewtopic.php?t=5979&highlight=mqji

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        【解决方案3】:

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

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

        【讨论】:

          【解决方案4】:

          原来这个错误是因为我定义了队列连接工厂 在服务器级别(在 WebSphere v6 服务器上)并且使用了错误的类加载器 加载上述属性文件。

          我通过在单元级别重新定义工厂解决了这个问题。

          【讨论】:

            【解决方案5】:

            由于您将收到错误消息,因此消息目录也毫无用处,这里有一个 mq.jar 的小补丁:

            1. 烦死了
            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。

            您将获得“MQJE001: FAILED NOT_AUTHORIZED”而不是 MQJE001: RC 2 CC 2035

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2012-10-01
              • 2015-06-21
              • 2010-10-01
              • 2015-06-22
              • 1970-01-01
              相关资源
              最近更新 更多