2013-07-23 185 views
2

我嘗試通過Spring爲WebSphere MQ開發測試客戶端(Java Web應用程序)。用於WebSphere MQ的SSL Java客戶端

我已經使用NULL_MD5密碼規範爲通道,隊列管理器和連接工廠啓用了SSL安全機制。

這是我的Spring配置文件:

<beans xmlns="http://www.springframework.org/schema/beans" 
     xmlns:context="http://www.springframework.org/schema/context" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-2.5.xsd 
http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> 

    <context:annotation-config/> 

    <context:property-placeholder location="classpath:jms.properties"/> 

    <bean id="jmsFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory"> 
     <property name="hostName" value="${queue_hostname}"/> 
     <property name="queueManager" value="${queue_manager}"/> 
     <property name="channel" value="${queue_channel}"/> 
     <property name="port" value="${queue_port}"/> 
     <property name="transportType" value="1"/> 
     <property name="SSLCipherSuite" value="SSL_RSA_WITH_NULL_MD5"/> 
    </bean> 

    <bean id="sendDestination" class="com.ibm.mq.jms.MQQueue"> 
     <property name="baseQueueName"> 
      <value>queue.inbound</value> 
     </property> 
    </bean> 

    <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate"> 
     <property name="connectionFactory"> 
      <bean class="org.springframework.jms.connection.SingleConnectionFactory"> 
       <property name="targetConnectionFactory"> 
        <ref local="jmsFactory" /> 
       </property> 
      </bean> 
     </property> 
     <property name="defaultDestination"> 
      <ref bean="sendDestination" /> 
     </property> 
    </bean> 


    <bean id="messageListener" class="com.test.MessageListener" /> 

    <bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer"> 
     <property name="connectionFactory"> 
      <bean class="org.springframework.jms.connection.SingleConnectionFactory"> 
       <property name="targetConnectionFactory"> 
        <ref local="jmsFactory" /> 
       </property> 
      </bean> 
     </property> 
     <property name="destination" ref="sendDestination" /> 
     <property name="messageListener" ref="messageListener" /> 
    </bean> 

</beans> 

問題是,當我嘗試連接到WebSphere MQ異常引發:

Caused by: org.springframework.context.ApplicationContextException: Failed to start bean 'jmsContainer'; nested exception is java.lang.AssertionError 
    at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:170) 
    at org.springframework.context.support.DefaultLifecycleProcessor.access$1(DefaultLifecycleProcessor.java:154) 
    at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:339) 
    at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:143) 
    at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:108) 
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:926) 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:467) 
    at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:103) 
    at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:1) 
    at org.springframework.test.context.support.DelegatingSmartContextLoader.loadContext(DelegatingSmartContextLoader.java:228) 
    at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:124) 
    at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:148) 
    ... 27 more 
Caused by: java.lang.AssertionError 
    at com.ibm.mq.jmqi.internal.CipherSpec.<init>(CipherSpec.java:53) 
    at com.ibm.mq.jmqi.JmqiUtils.toCipherSuite(JmqiUtils.java:325) 
    at com.ibm.mq.jmqi.remote.impl.RemoteTCPConnection.parseCipherSpec(RemoteTCPConnection.java:1984) 
    at com.ibm.mq.jmqi.remote.impl.RemoteTCPConnection.makeSocketSecure(RemoteTCPConnection.java:1838) 
    at com.ibm.mq.jmqi.remote.impl.RemoteTCPConnection.connnectUsingLocalAddress(RemoteTCPConnection.java:810) 
    at com.ibm.mq.jmqi.remote.impl.RemoteTCPConnection.protocolConnect(RemoteTCPConnection.java:1130) 
    at com.ibm.mq.jmqi.remote.impl.RemoteConnection.connect(RemoteConnection.java:710) 
    at com.ibm.mq.jmqi.remote.impl.RemoteConnectionSpecification.getSessionFromNewConnection(RemoteConnectionSpecification.java:400) 
    at com.ibm.mq.jmqi.remote.impl.RemoteConnectionSpecification.getSession(RemoteConnectionSpecification.java:299) 
    at com.ibm.mq.jmqi.remote.impl.RemoteConnectionPool.getSession(RemoteConnectionPool.java:164) 
    at com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:1595) 
    at com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:1223) 
    at com.ibm.mq.ese.jmqi.InterceptedJmqiImpl.jmqiConnect(InterceptedJmqiImpl.java:311) 
    at com.ibm.mq.ese.jmqi.ESEJMQI.jmqiConnect(ESEJMQI.java:337) 
    at com.ibm.msg.client.wmq.internal.WMQConnection.<init>(WMQConnection.java:346) 
    at com.ibm.msg.client.wmq.factories.WMQConnectionFactory.createV7ProviderConnection(WMQConnectionFactory.java:6876) 
    at com.ibm.msg.client.wmq.factories.WMQConnectionFactory.createProviderConnection(WMQConnectionFactory.java:6254) 
    at com.ibm.msg.client.jms.admin.JmsConnectionFactoryImpl.createConnection(JmsConnectionFactoryImpl.java:285) 
    at com.ibm.mq.jms.MQConnectionFactory.createCommonConnection(MQConnectionFactory.java:6189) 
    at com.ibm.mq.jms.MQQueueConnectionFactory.createQueueConnection(MQQueueConnectionFactory.java:120) 
    at com.ibm.mq.jms.MQQueueConnectionFactory.createConnection(MQQueueConnectionFactory.java:203) 
    at org.springframework.jms.connection.SingleConnectionFactory.doCreateConnection(SingleConnectionFactory.java:342) 
    at org.springframework.jms.connection.SingleConnectionFactory.initConnection(SingleConnectionFactory.java:288) 
    at org.springframework.jms.connection.SingleConnectionFactory.createConnection(SingleConnectionFactory.java:225) 
    at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:184) 
    at org.springframework.jms.listener.AbstractJmsListeningContainer.createSharedConnection(AbstractJmsListeningContainer.java:403) 
    at org.springframework.jms.listener.AbstractJmsListeningContainer.establishSharedConnection(AbstractJmsListeningContainer.java:371) 
    at org.springframework.jms.listener.DefaultMessageListenerContainer.establishSharedConnection(DefaultMessageListenerContainer.java:750) 
    at org.springframework.jms.listener.AbstractJmsListeningContainer.doStart(AbstractJmsListeningContainer.java:278) 
    at org.springframework.jms.listener.AbstractJmsListeningContainer.start(AbstractJmsListeningContainer.java:263) 
    at org.springframework.jms.listener.DefaultMessageListenerContainer.start(DefaultMessageListenerContainer.java:556) 
    at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:167) 
    ... 38 more 

奇怪的是,即使我設置SSLCipherSuite屬性,它試圖通過密碼規範得到密碼套件...

有人可以請建議如何解決這個問題嗎?

回答

0

那麼,經過一番研究後,問題出現在斷言機制中。如果斷言被禁用,一切正常。奇怪的是,即使斷言失敗,你也可以擁有一個完整的工作代碼......而且很遺憾,我找不到設置密碼規範的方法 - 只有密碼套件設置器由MQQueueConnectionFactory類提供。

如果是weblogic服務器,則會在WLS_HOME/user_projects/domains/local-domain-name/bin/setDomainEnv.cmd(.sh)中驗證名爲'debugFlag'的參數。如果您將其設置爲「true」,則應用程序將失敗。或者,您可以在setDomainEnv.cmd(.sh)文件的末尾添加以下JAVA_OPTION:-da:com.ibm.mq ...。通過這種方式,您可以啓用調試。

對於cource來說,解決問題並不是一個可取的方法,但現在它是我能解決這個問題的唯一方法。

1

這個bug在這裏承認:http://www-01.ibm.com/support/docview.wss?uid=swg1IV36662

並標記爲固定在WebSphere MQ修訂包7.1.0.3。

推薦的(但不是完全令人滿意的)解決方法是使用「-disableassertions」或「-da」禁用JRE命令行中的斷言。

+0

這也意味着在這篇文章中遇到這個問題的任何人都將使用MQ的不受支持的版本,並且如果他們希望在Production中獲得支持,應該着眼於升級。 –

+0

@ T.Rob 7.1已經支持到4月底:) – JoshMc

+0

高級讀寫困難時刻?我首先將它讀作7.0.1.3。所以,是的,在接下來的幾個月中某個時候會升級。雖然沒有那麼迫切,但比在有效期限之後發現它要好。 –