Harshil Desai [https://community.jboss.org/people/harshildesai] created the 
discussion

"JBoss with Websphere MQ connection issue: DetailedIllegalStateException"

To view the discussion, visit: https://community.jboss.org/message/716864#716864

--------------------------------------------------------------
Hi

We connect to WebspehereMQ for sending and receiving the JMS messages in our 
JBoss EAP 4.2 app server - this was all working fine. Now there has been an 
upgrade of the WMQ series from version 5.2 to 7. We have been provided with the 
new libraries and new hostName for making this change at our end.

I have made the following changes:
- updated the hostName in custom datasource file +ful-jms-ds.xml + which looks 
like this:

<connection-factories>

  <tx-connection-factory> 
    <jndi-name>MyTestQueueConnectionFactory</jndi-name>
    <xa-transaction />
    <rar-name>wmq.jmsra.rar</rar-name>
    <connection-definition>javax.jms.ConnectionFactory</connection-definition>
    <config-property name="channel" 
type="java.lang.String">JAVA.CHANNEL</config-property>
    <config-property name="hostName" 
type="java.lang.String">myserver</config-property>
    <config-property name="port" 
type="java.lang.String">myport</config-property>
    <config-property name="queueManager" 
type="java.lang.String">MYTEST.MW</config-property>
    <config-property name="transportType" 
type="java.lang.String">CLIENT</config-property>
    
<security-domain-and-application>JmsXARealm</security-domain-and-application>
  </tx-connection-factory>

  <!-- admin object definition Queue Setting -->
       <mbean code="org.jboss.resource.deployment.AdminObject" 
name="jca.wmq:name=myTestQueue">
         <attribute name="JNDIName">TestQueue</attribute>
         <depends 
optional-attribute-name="RARName">jboss.jca:service=RARDeployment,name='wmq.jmsra.rar'</depends>
         <attribute name="Type">javax.jms.Queue</attribute> 
         <attribute name="Properties">
           baseQueueManagerName=MYTEST.MW
           baseQueueName=MYTESTSQL.ECOMMERCEORDERS
         </attribute>
 </mbean>
</connection-factories>


- Replaced the deployer file +wmq.jmsra.rar+ with the new one at 
+JBOSS_HOME/server/server_name/deploy/+ directory

The JNDI lookup and connection creation is done from the Java class in the ear. 
There are no WMQ specific classes used in the java class hence no libraries 
need to be changed in the ear. Here is the method

public void sendMessage(String textMessage, String jndiQueueConnFactory , 
String jndiQueue) throws JMSException , SystemException
    {
        Connection tempConnection = null;
        private ConnectionFactory queueConnectionFactory_OFS;
 
        try 
        {
            Context  ctx = new InitialContext();
            if(null == queueConnectionFactory_OFS)
            {
                queueConnectionFactory_OFS = 
(ConnectionFactory)ctx.lookup(jndiQueueConnFactory);                
            }
            
            if(null == queue_OFS)
                queue_OFS = (Queue) ctx.lookup(jndiQueue);    
            
            tempConnection = queueConnectionFactory_OFS.createConnection();
            tempConnection.start();
            Session session = tempConnection.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
            MessageProducer producer = session.createProducer(queue_OFS);
            TextMessage message = session.createTextMessage();
            message.setText(textMessage);
            producer.send(message);
                        
            if(null != tempConnection)
            {
                tempConnection.stop();
                tempConnection.close();
            }
        } 
        catch (JMSException e) 
        {
            throw new SystemException("JMSException while connecting to Queue");
        }
        catch(NamingException ne)        
        {
                throw new SystemException("NamingException while connecting to 
Queue"); 
        }
    }



When i send the JMS messages, the message do reach the new queues, however, 
there are exception in the logs which i suspect is coming while closing the 
connection:

2012-02-13 07:47:35,302 ERROR [STDERR] 
com.ibm.msg.client.jms.DetailedIllegalStateException: MQJCA1031: The method can 
only be called in the application client container. 
The application was not running in the application client container when this 
method was called.  Ensure that the application runs in the application client 
container, 
or modify the application to avoid this method call.
2012-02-13 07:47:35,303 ERROR [STDERR]  at 
com.ibm.mq.connector.services.JCAExceptionBuilder.buildException(JCAExceptionBuilder.java:149)
2012-02-13 07:47:35,303 ERROR [STDERR]  at 
com.ibm.mq.connector.services.JCAExceptionBuilder.buildException(JCAExceptionBuilder.java:86)
2012-02-13 07:47:35,303 ERROR [STDERR]  at 
com.ibm.mq.connector.outbound.ConnectionWrapper.stop(ConnectionWrapper.java:221)



Can you please help me. Let me know if you need any other information.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/716864#716864]

Start a new discussion in Beginner's Corner at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2075]

_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to