Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 什么是;“未找到邮件目录”;什么意思?_Java_Websphere_Message Queue - Fatal编程技术网

Java 什么是;“未找到邮件目录”;什么意思?

Java 什么是;“未找到邮件目录”;什么意思?,java,websphere,message-queue,Java,Websphere,Message Queue,我在WebSphere中运行了一个MDB,它试图从MQ队列中提取消息 将引发以下异常: com.ibm.mq.MQException:未找到消息目录 你知道如何解决这个问题吗?谷歌说这是类路径中的一个遗漏条目: 将包含mqji.properties文件的目录添加到类路径中mqji.properties文件已包含在mqjar文件中 Message Catalog not found异常作为“MQJMS2002:未能从MQ队列获取消息”的一部分引发。事实证明,引发此错误是因为我定义了队列连接工厂 在

我在WebSphere中运行了一个MDB,它试图从MQ队列中提取消息 将引发以下异常:

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


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

谷歌说这是类路径中的一个遗漏条目:

将包含mqji.properties文件的目录添加到类路径中

mqji.properties文件已包含在mqjar文件中


Message Catalog not found异常作为“MQJMS2002:未能从MQ队列获取消息”的一部分引发。

事实证明,引发此错误是因为我定义了队列连接工厂 在服务器级别(WebSphereV6服务器上),使用了错误的类加载器 加载上述属性文件


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

由于您将从消息目录中获得的错误消息也非常无用,因此这里有一个针对mq.jar的小补丁:

  • 抓狂
  • 反汇编MQException和MQInternalException(后者是必需的,因为它继承自MQException;我们不会更改它)
  • 将此代码添加到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);
            }
        }
    
  • 将这两个类编译成一个新的jar或修补原始的mq.jar

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

        // 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;
        }