我有一個基於JMS的應用程序,我在Websphere 6.0上運行,並且正在遷移到Websphere 7.兩個Websphere服務器都使用Websphere MQ 6.0服務器。我收到試圖測試的servlet部署到WebSphere 7服務器時出現以下異常:javax.jms.JMSSecurityException:MQJMS2008:無法打開MQ隊列
javax.jms.JMSSecurityException:MQJMS2008:未能打開MQ隊列
的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 [email protected] 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服務器相同的隊列和連接工廠。我對如何解決這個問題感到不知所措,Google對此毫無幫助。
更新2011-04-15: 我從日誌中提取以下錯誤:
com.ibm.mq.MQException:MQJE001:完成代碼 '2',原因是「2035 '
我已經在幾處讀過它,我真的不知道WAS 6和WAS 7之間有什麼區別導致這個問題。
我在兩臺Linux主機上以root身份運行websphere。我有完全權限MQ安裝在Windows機器上創建一個root帳戶:
的setmqaut -t QMGR -m QM_webspheremq -p根+所有
SecurityException表示您需要提供連接憑據。 – 2011-04-13 20:13:22
你會這樣想,但我似乎並不需要它們。我沒有爲Websphere 6.0(作品)配置任何配置,並且讓他們/沒有他們似乎對Websphere 7(!works)沒有任何影響。 – 2011-04-13 20:34:08