首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >javax.jms.JMSSecurityException: MQJMS2008:未能打开MQ队列

javax.jms.JMSSecurityException: MQJMS2008:未能打开MQ队列
EN

Stack Overflow用户
提问于 2011-04-13 19:30:47
回答 2查看 14.8K关注 0票数 3

我有一个基于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

WebSphereMQ6.0: Windows 2003

Servlet测试代码:

代码语言:javascript
运行
复制
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 {
        }
    }

属性文件是:

代码语言:javascript
运行
复制
MQConnectionFactory=jms/QUEUECONNFACTORY
MQQueue=jms/QUEUE 

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

代码语言:javascript
运行
复制
[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和can 7之间有什么不同导致了这个问题。

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

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

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-01-06 08:34:58

从2019年1月开始,每四个月我就会回复这个旧帖子,因为它每四个月就会被社区用户“撞”一次。

首先是一些背景:

  • 是6.0

代码语言:javascript
运行
复制
- Included MQ jar files from Websphere MQ v5.3
- Depending on the specific version of WAS 6.0, the jars would be from Websphere MQ v5.3 CSD08 up to CSD14

  • 为7.0.0.15

代码语言:javascript
运行
复制
- Is supposed to include WebSphere MQ JCA resource adapter Version 7.0.1.3 (the default behavior here would have been that of the MQ v5.3 jars), but because of a bug, if you upgraded from WAS 7.0.0.0 to WAS 7.0.0.15, the WebSphere MQ JCA resource adapter Version 7.0.0.0 which came with WAS 7.0.0.0 would stay in place.

不同之处:

带有MQV5.3JAR文件的

  • ,当您调用fact.createQueueConnection();时,将向队列管理器发送一个空白的userid。如果连接到的SVRCONN通道有一个空白的MCAUSER属性,那么连接将在Windows队列管理器运行的用户帐户的授权下运行。换句话说,您将完全授权队列管理器和所有队列(完整MQ管理authority).
  • With MQ v7.0.0.0资源适配器,当您调用fact.createQueueConnection();时,JVM将被发送到队列管理器。如果连接到的root.

通道有一个空白的MCAUSER属性,那么Windows队列管理器将尝试在JVM进程ID的授权下运行连接。

摘要:

它在Websphere 6.0下工作,因为连接具有完整的MQ管理权限。

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

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

可以通过向QUEUE用户提供root授权来解决这一问题:

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

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

票数 1
EN

Stack Overflow用户

发布于 2016-11-04 15:37:56

我也犯了同样的错误。检查您的端口,队列管理器和队列details.For me --这是不正确的通道。

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

有关原因代码的更多信息,请打开CMD并键入mqrc。

分析您的错误,看起来您可以访问该队列,我有一些问题:

您正在使用JNDI连接吗?如果您正在与使PTP连接(我指的是不使用MQQueueConnectionFactory )的类连接,则必须为http://hursleyonwmq.wordpress.com/2007/05/29/simplest-sample-applications-using-websphere-mq-jms/提供通道、队列管理器、队列名称和服务器主机名,如果您想了解更多关于PTP连接的信息,下面是:http://hursleyonwmq.wordpress.com/2007/05/29/simplest-sample-applications-using-websphere-mq-jms/

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

如果您可以提供嵌套的异常,我将帮助您。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5654547

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档