Topic
5 replies Latest Post - ‏2010-03-05T09:55:24Z by Joltan
Joltan
Joltan
4 Posts
ACCEPTED ANSWER

Pinned topic Problem connecting to Websphere MQ 6

‏2010-03-02T23:24:37Z |
I'm having troubles connecting to a Websphere MQ 6 using WASCE 2.1.1.3. But I'm getting the following exception


+MQJMS0003: Zieladresse nicht bekannt bzw. nicht mehr gültig Throwing Exception 

for object: com.ibm.mq.connector.outbound.MQQueueProxy@2f782f78 Object 

class                 : 

class $Proxy49 Object classLoader           : [org.apache.geronimo.kernel.classloader.JarFileClassLoader id=de.identytec/idconnector/1.0/war] CurrentThread ClassLoader    : [org.apache.geronimo.kernel.classloader.JarFileClassLoader id=de.identytec/idconnector/1.0/war]
"


I have no mq libs in my application's war file, everything regarding messaging is provided by the app server. Now when I switch to using Spring instead of plain jms, I get the following exception instead:

javax.jms.JMSException: MQJCA1026:Invalid operation 

for a domain specific object. at com.ibm.mq.connector.services.JCAExceptionBuilder.buildException(JCAExceptionBuilder.java:113) at com.ibm.mq.connector.services.JCAExceptionBuilder.buildException(JCAExceptionBuilder.java:78) at com.ibm.mq.connector.outbound.QueueConnectionFactoryImpl.createConnection(QueueConnectionFactoryImpl.java:75) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:618) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198) at $Proxy53.createConnection(Unknown Source) at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:184) at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:461) at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:539) at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:531)


Any ideas? In both cases I access the ConnectionFactory and the Queue using jndi lookup - with no other applications using them. I've searched around a lot but none of the solutions I found for these errors helped me any further... The server address and port are valid - I can even see the client connecting to the mq using the MQ Explorer - nothing is written into the queue tho.

Here's my deplyoment plan for wmq.jmsra.rar:

<?xml version=
"1.0" encoding=
"UTF-8"?> <connector xmlns=
"http://geronimo.apache.org/xml/ns/j2ee/connector-1.2"> <dep:environment xmlns:dep=
"http://geronimo.apache.org/xml/ns/deployment-1.2"> <moduleId> <groupId>myApp</groupId> <artifactId>JMSResourceAdapter</artifactId> <version>1.0</version> <type>rar</type> </moduleId> </dep:environment> <resourceadapter> <resourceadapter-instance> <resourceadapter-name>JMSResourceGroup</resourceadapter-name> <config-property-setting name=
"traceEnabled">true</config-property-setting> <config-property-setting name=
"traceLevel">10</config-property-setting> <config-property-setting name=
"traceDestination">wmq_jca.trc</config-property-setting> <workmanager> <gbean-link>DefaultWorkManager</gbean-link> </workmanager> </resourceadapter-instance> <outbound-resourceadapter> <connection-definition> <connectionfactory-interface>javax.jms.QueueConnectionFactory</connectionfactory-interface> <connectiondefinition-instance> <name>MQConnectionFactory</name> <implemented-interface>javax.jms.QueueConnectionFactory</implemented-interface> <config-property-setting name=
"queueManager">TESTQM</config-property-setting> <config-property-setting name=
"channel">SYSTEM.DEF.SVRCONN</config-property-setting> <config-property-setting name=
"transportType">CLIENT</config-property-setting> <config-property-setting name=
"hostName">192.168.0.240</config-property-setting> <config-property-setting name=
"port">3435</config-property-setting> <connectionmanager> <local-transaction /> <single-pool> <max-size>50</max-size> <min-size>10</min-size> <blocking-timeout-milliseconds>5000</blocking-timeout-milliseconds> <idle-timeout-minutes>2</idle-timeout-minutes> <match-all /> </single-pool> </connectionmanager> </connectiondefinition-instance> </connection-definition> </outbound-resourceadapter> </resourceadapter>   <adminobject> <adminobject-interface>javax.jms.Queue</adminobject-interface> <adminobject-class>com.ibm.mq.connector.outbound.MQQueueProxy</adminobject-class> <adminobject-instance> <message-destination-name>OutboundQueue</message-destination-name> <config-property-setting name=
"baseQueueName">MYQUEUE</config-property-setting> <config-property-setting name=
"baseQueueManagerName">TESTQM</config-property-setting> </adminobject-instance> </adminobject> </connector>


Here's the geronimo-web.xml:

<web-app xmlns=
"http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1" xmlns:sys=
"http://geronimo.apache.org/xml/ns/deployment-1.2" xmlns:name=
"http://geronimo.apache.org/xml/ns/naming-1.2"> <sys:environment> <sys:moduleId> <sys:groupId>net.myComp</sys:groupId> <sys:artifactId>myApp</sys:artifactId> <sys:version>1.0</sys:version> <sys:type>war</sys:type> </sys:moduleId>     <sys:dependencies> <sys:dependency> <sys:groupId>console.dbpool</sys:groupId> <sys:artifactId>myDatabaseConnection</sys:artifactId> </sys:dependency> <!-- Start MQ Settings --> <sys:dependency> <sys:groupId>myApp</sys:groupId> <sys:artifactId>JMSResourceAdapter</sys:artifactId> <sys:version>1.0</sys:version> <sys:type>rar</sys:type> </sys:dependency> <!-- End MQ Settings --> </sys:dependencies>   <sys:hidden-classes> <sys:filter>antlr</sys:filter> <sys:filter>net.sf.cglib</sys:filter> <sys:filter>net.sf.ehcache</sys:filter> <sys:filter>org.aopalliance.aop</sys:filter> <sys:filter>org.aopalliance.intercept</sys:filter> <sys:filter>org.apache.commons.collections</sys:filter> <sys:filter>org.apache.commons.fileupload</sys:filter> <sys:filter>org.apache.commons.logging</sys:filter> <sys:filter>org.apache.commons.codec</sys:filter> <sys:filter>org.apache.log4j</sys:filter> <sys:filter>org.dom4j</sys:filter> <sys:filter>org.jaxen</sys:filter> <sys:filter>org.jdom</sys:filter> <sys:filter>org.objectweb.asm</sys:filter> <sys:filter>org.hibernate</sys:filter> <sys:filter>org.realityforge.jmxtools</sys:filter> <sys:filter>org.springframework</sys:filter>   </sys:hidden-classes>   </sys:environment> <context-root>/myApp</context-root>   <name:resource-ref> <name:ref-name>jdbc/DATABASE</name:ref-name> <name:resource-link>myDatabaseConnection</name:resource-link> </name:resource-ref>   <!-- Start MQ Settings --> <name:resource-ref> <name:ref-name>jms/MQFACTORY</name:ref-name> <name:resource-link>MQConnectionFactory</name:resource-link> </name:resource-ref> <name:resource-env-ref> <name:ref-name>jms/OUTQUEUE</name:ref-name> <name:message-destination-link>OutboundQueue</name:message-destination-link> </name:resource-env-ref> <!-- End MQ Settings --> </web-app>
Updated on 2010-03-05T09:55:24Z at 2010-03-05T09:55:24Z by Joltan
  • Forrest_Xia
    Forrest_Xia
    82 Posts
    ACCEPTED ANSWER

    Re: Problem connecting to Websphere MQ 6

    ‏2010-03-04T01:12:24Z  in response to Joltan
    Hi,

    Can you share with your sample application that hit this exception?

    Forrest
    • Joltan
      Joltan
      4 Posts
      ACCEPTED ANSWER

      Re: Problem connecting to Websphere MQ 6

      ‏2010-03-04T11:42:55Z  in response to Forrest_Xia
      Not the complete App, but the relevant portions:

      First the relevant part from my ApplicationContext:
      
      <jee:jndi-lookup id=
      "jmsConnectionFactory" resource-ref=
      "true" jndi-name=
      "jms/MQFACTORY" proxy-interface=
      "javax.jms.QueueConnectionFactory" /> <jee:jndi-lookup id=
      "jmsOutboundQueue" resource-ref=
      "true" jndi-name=
      "jms/OUTQUEUE" proxy-interface=
      "javax.jms.Queue" /> <bean id=
      "jmsTemplateOutgoing" class=
      "org.springframework.jms.core.JmsTemplate102"> <property name=
      "connectionFactory" ref=
      "jmsConnectionFactory"/> <property name=
      "defaultDestination" ref=
      "jmsOutboundQueue"/> </bean>
      

      And then the code (using either Spring JmsTemplate or plain JMS):
      
      
      
      public 
      
      void sendSpringMap(
      
      final Map<String, String> fields) 
      
      throws JmsException 
      { 
      
      try 
      { this.getJmsTemplate().send( 
      
      new MessageCreator() 
      {   
      
      public Message createMessage(javax.jms.Session session) 
      
      throws JMSException 
      { MapMessage msg = session.createMapMessage(); 
      
      for (String key : fields.keySet()) 
      { msg.setString(key, fields.get(key)); 
      } 
      
      return msg; 
      } 
      }); 
      } 
      
      catch (JmsException t) 
      { this.setLastException(t); log.error(
      "JMS Exception while sending message!",t.getMostSpecificCause()); 
      
      throw t; 
      } 
      } 
      
      public 
      
      void sendMap(
      
      final Map<String, String> map) 
      
      throws JMSException 
      { QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory)AppContextTool.getAppContextBean(
      "jmsConnectionFactory"); Queue queueOut = (Queue)AppContextTool.getAppContextBean(
      "jmsOutboundQueue"); QueueConnection con = 
      
      null; QueueSession session = 
      
      null; 
      
      try 
      { con = queueConnectionFactory.createQueueConnection(); session = con.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); MessageProducer prod = session.createSender(queueOut); MapMessage msg = session.createMapMessage(); 
      
      for (String key : fields.keySet()) 
      { msg.setString(key, fields.get(key)); 
      } prod.send(msg); 
      } 
      
      catch (JMSException t) 
      { log.error(
      "JMSException while sending message!", t); 
      
      throw t; 
      } 
      
      finally 
      { 
      
      try 
      {   
      
      if (session != 
      
      null) 
      { session.close(); 
      } 
      
      if (con != 
      
      null) 
      { con.close(); 
      } 
      } 
      
      catch (JMSException t) 
      { log.error(
      "JMXException", t); 
      } 
      } 
      }
      
      • Forrest_Xia
        Forrest_Xia
        82 Posts
        ACCEPTED ANSWER

        Re: Problem connecting to Websphere MQ 6

        ‏2010-03-04T12:59:32Z  in response to Joltan
        Two questions:
        1. How about just use JmsTemplate not JmsTemplate102?
        2. Can you paste the full exception stack? especially which line of code in your app that trigger the problem?

        I don't have Spring JmsTemplate runnable sample locally, so it's hard to make an environment to recur your problem and then determine where the problem is. So if you have a runnable sample, that would be helpful for me to help you on this.

        Forrest
        • Joltan
          Joltan
          4 Posts
          ACCEPTED ANSWER

          Re: Problem connecting to Websphere MQ 6

          ‏2010-03-05T09:51:17Z  in response to Forrest_Xia
          JmsTemplate instead of JmsTemplate102 gives the same exception. The source of the exception is this line (the JmsTemplate.send(...) method, not the inner method - I've checked that with some additional exception handling and logging):
          
          this.getJmsTemplate().send( 
          
          new MessageCreator() 
          { 
          
          public Message createMessage(javax.jms.Session session) 
          
          throws JMSException 
          { MapMessage msg = session.createMapMessage(); 
          
          for (String key : fields.keySet()) 
          { msg.setString(key, fields.get(key)); 
          } 
          
          return msg; 
          } 
          });
          


          The stacktrace is as follows:
          
          10:38:58,854  INFO HeartbeatMqHandler:26 - sending heartbeat 
          '#20100305103858' to MQ...   10:38:58,869 ERROR BaseMqMapMessageHandler:88 - JMS Exception 
          
          while sending message!   javax.jms.JMSException: MQJCA1026:Invalid operation 
          
          for a domain specific object.   at com.ibm.mq.connector.services.JCAExceptionBuilder.buildException(JCAExceptionBuilder.java:113)   at com.ibm.mq.connector.services.JCAExceptionBuilder.buildException(JCAExceptionBuilder.java:78)   at com.ibm.mq.connector.outbound.QueueConnectionFactoryImpl.createConnection(QueueConnectionFactoryImpl.java:75)   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)   at java.lang.reflect.Method.invoke(Method.java:618)   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198)   at $Proxy48.createConnection(Unknown Source)   at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:184)   at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:461)   at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:539)   at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:531)   at de.identytec.messaging.BaseMqMapMessageHandler.sendSpringMap(BaseMqMapMessageHandler.java:62)
          

          I definitely think the problem with accessing the queue lies in the way I've configured the queue in WASCE (see my first post for details), not in the coding itself.

          I'll try to prepare a small demo based on my code later.
          • Joltan
            Joltan
            4 Posts
            ACCEPTED ANSWER

            Re: Problem connecting to Websphere MQ 6

            ‏2010-03-05T09:55:24Z  in response to Joltan
            I should add, that the code works fine with the ActiveMQ embedded with WASCE or with Glassfish and it's MQ (not sure what that one is).