javax.jms.JMSSecurityException: MQJMS2008: failed to open MQ



我有一个基于jms的应用程序,我在Websphere 6.0上运行,并且要迁移到Websphere 7。这两个Websphere服务器都由Websphere MQ 6.0服务器提供支持。当尝试将测试servlet部署到Websphere 7服务器时,我收到以下异常:

javax.jms.JMSSecurityException: MQJMS2008: failed to open MQ queue

Websphere 6.0: RHEL 5.3

Websphere 7.0.0.15: RHEL 5.3

Websphere MQ 6.0: Windows Server 2003

Servlet测试代码:
public class JMSTestServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    /**
     * @see HttpServlet#HttpServlet()
     */
        String MQConnectionFactory, MQQueue; 
    public JMSTestServlet() {
        super();
        // TODO Auto-generated constructor stub
        System.out.println("JMSTestServlet: loading");
        URL urlProps = getClass().getClassLoader().getResource("META-INF/startup.properties");
        Properties props = new Properties();
        try
                {
          System.out.println("JMSTestServlet: loading properties");
          props.load( urlProps.openStream() );
                    MQConnectionFactory = props.getProperty("MQConnectionFactory"); 
                    MQQueue = props.getProperty("MQQueue"); 
          System.out.println("JMSTestServlet: loading properties ... done!");
          sendMessage("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
                } catch (IOException e)
                {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
    }
    protected void sendMessage(String messageString) { 
        QueueConnectionFactory fact;
        QueueConnection qConn = null;
        try { 
            System.out.println("JMSTestServlet: creating context");
            Context ctx = new InitialContext();
            fact = (QueueConnectionFactory)ctx.lookup(MQConnectionFactory);
            Destination destination = (Destination)ctx.lookup(MQQueue);
            System.out.println("JMSTestServlet: creating QueueConnection");
            qConn = fact.createQueueConnection(); 
            QueueSession    qSess = qConn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
            MessageProducer prod = qSess.createProducer(destination); 

            System.out.println("JMSTestServlet: sending Message");
            TextMessage message = qSess.createTextMessage();
            message.setText(messageString);
            prod.send(message); 
            System.out.println("JMSTestServlet: done sendMessage()");
        } catch ( JMSException ex ) {
            ex.toString(); 
            ex.printStackTrace();
            ex.getLinkedException().toString();
            ex.getLinkedException().printStackTrace();
        } catch ( NamingException ex ) {
            System.out.println("JMSTestServlet: naming exception " + ex.toString());
            ex.printStackTrace();
        } catch ( Exception ex ) {
          System.out.println("JNDI API lookup failed: " +         ex.toString());
            ex.printStackTrace();           
        } finally {
            System.out.println("JMSTestServlet: cleaning up sendMessage()");
            try
            {
                if ( qConn != null ) qConn.close();
            } catch (JMSException e)
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }
    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        try { 
            String messageString = request.getParameter("message"); 
            sendMessage(messageString);
        } finally {
        }
    }

属性文件是:

MQConnectionFactory=jms/QUEUECONNFACTORY
MQQueue=jms/QUEUE 

部署到Websphere 6时,我在远程队列中获得消息。当我部署到Websphere 7时,得到:

[4/13/11 14:53:55:622 EDT] 0000005c ConnectionEve A   J2CA0056I: The Connection Manager received a fatal connection error from the Resource Adapter for resource JMS$QUEUECONNFACTORY$JMSManagedConnection@15. The exception is: javax.jms.JMSSecurityException: MQJMS2008: failed to open MQ queue 'QUEUE'.
[4/13/11 14:53:55:622 EDT] 0000005c ConnectionEve W   J2CA0206W: A connection error occurred.  To help determine the problem, enable the Diagnose Connection Usage option on the Connection Factory or Data Source.
[4/13/11 14:53:55:623 EDT] 0000005c ConnectionEve A   J2CA0056I: The Connection Manager received a fatal connection error from the Resource Adapter for resource jms/QUEUECONNFACTORY. The exception is: javax.jms.JMSSecurityException: MQJMS2008: failed to open MQ queue 'QUEUE'.
[4/13/11 14:53:55:625 EDT] 0000005c SystemErr     R   javax.jms.JMSSecurityException: MQJMS2008: failed to open MQ queue 'QUEUE'.

我很确定我已经在两个Websphere服务器上配置了相同的队列和连接工厂。我不知道如何解决这个问题,谷歌也帮不上忙。

更新2011-04-15:

我从日志中提取了以下错误:

com.ibm.mq.MQException: MQJE001: Completion Code '2', Reason '2035'

我已经在几个地方读过了,我真的看不出WAS 6和WAS 7之间有什么区别会导致这个问题。

我以root身份在两台Linux主机上运行Websphere。我在Windows机器上创建了一个root帐户,具有MQ安装的完全权限:

setmqaut -t qmgr -m QM_webspheremq -p root +all

自2019年1月以来,每四个月就会被"社区用户挤掉",所以我将尝试回答这个旧帖子。


先介绍一下背景:

  • WAS 6.0

    • 包含来自Websphere MQ v5.3的MQ jar文件
    • 根据WAS 6.0的具体版本,jar将从Websphere MQ v5.3 CSD08到CSD14
  • 是7.0.0.15

    • 应该包含WebSphere MQ JCA资源适配器版本7.0.1.3(这里的默认行为将是MQ v5.3 jar),但是由于一个错误,如果您从WAS 7.0.0.0升级到WAS 7.0.0.15,那么与WAS 7.0.0.0一起附带的WebSphere MQ JCA资源适配器版本7.0.0.0将保持不变。

的区别:

  • 对于MQ v5.3 jar文件,当您调用fact.createQueueConnection();时,将向队列管理器发送一个空白用户id。如果您连接到的SVRCONN通道有一个空白的MCAUSER属性,那么该连接将在Windows MQ队列管理器运行时使用的用户帐户的权限下运行。换句话说,您将获得队列管理器和所有队列的完全权限(完整的MQ管理权限)。

  • 使用MQ v7.0.0.0资源适配器,当调用fact.createQueueConnection();时,JVM进程ID将被发送到队列管理器。如果您连接到的SVRCONN通道有一个空白的MCAUSER属性,那么Windows MQ队列管理器将尝试在JVM进程ID的权限下运行连接。根据你问题中的信息,这应该是用户root


概要:

它在Websphere 6.0下工作,因为连接以完整的MQ Admin权限运行。

在Websphere 7.0.0.15下失败,因为连接使用root用户权限运行,在本例中,您只向root用户提供了对队列管理器(qmgr)本身的all权限,而没有向QUEUE提供权限。

Websphere必须首先连接并查询队列管理器对象,然后才能打开任何队列。你得到的错误是javax.jms.JMSSecurityException: MQJMS2008: failed to open MQ queue 'QUEUE'.。这意味着您成功连接到队列管理器,但随后未能连接到队列。

这个问题可以通过向root用户提供QUEUE的权限来解决:

setmqaut -t q -m QM_webspheremq -n QUEUE -p root +put +get +browse +inq +dsp


注意,问题中列出的所有软件版本现在(8.5年后)都不再得到IBM的支持。另外,不建议使用具有空白MCAUSERSVRCONN通道,除非您使用其他方法,例如使用安全出口将MCAUSER设置为非mq Admin id。在当前的IBM MQ版本中,您可以使用将客户机证书映射到队列管理器上的非MQ Admin id的TLS,或者使用不使用证书+连接身份验证的TLS来验证客户机在队列管理器上发送的用户id和密码。

我也得到了同样的错误。检查您的端口、队列管理器和队列详细信息。对我来说,是频道不对。

其他用户:当您使用MQJMS2008时,您没有操作该队列的权限,您必须获得一个嵌套的Exception,该Exception为您提供有关错误的更多信息,并告诉您MQRC原因代码和终止代码。

有关Reason Code的更多信息,请打开CMD并输入mqrc

分析你的错误,看起来你被允许访问队列,我有一些问题:

是否使用JNDI连接?如果您正在连接一个进行PTP连接的类(我的意思是不使用JNDI),则必须向MQQueueConnectionFactory提供通道、队列管理器、队列名称和服务器的主机名,如果您想了解更多关于PTP连接的信息,请访问:http://hursleyonwmq.wordpress.com/2007/05/29/simplest-sample-applications-using-websphere-mq-jms/。

如果对远程队列执行此操作,并且在Windows上使用MQSeries而不是WMQ,则必须将所有特权授予公共。使用WRKMQMQ。

如果你能给出嵌套异常,我将帮助你。

相关内容

最新更新