|   | 
	 
  
    | 
RSS Feed - WebSphere MQ Support
 | 
RSS Feed - Message Broker Support
 |   
 
  
	     | 
	 | 
   
 
  
	|  Error invoking Java JMS program | 
	« View previous topic :: View next topic »  | 
   
  
  	
	  
		
		
		  | Author | 
		  Message
		 |  
		
		  | Gideon | 
		  
		    
			  
				 Posted: Mon Mar 18, 2013 2:10 pm    Post subject: Error invoking Java JMS program | 
				     | 
			   
			 
		   | 
		 
		
		   Chevalier
 
 Joined: 18 Aug 2009 Posts: 403
  
  | 
		  
		    
			  
				I am not a programmer.
 
 
I found the following JMS program at the following site:
 
 
http://hursleyonwmq.wordpress.com/2007/05/29/simplest-sample-applications-using-websphere-mq-jms/
 
 
I am running this on a Windows platform on which the WMQ 7.5 server is 
 
installed.  I copied the JMS jars to the local directory, and reference the lib file in the java invocation.
 
 
I rewrote the program as follows:
 
 
   
	| Code: | 
   
  
	import javax.jms.JMSException;
 
import javax.jms.Session;
 
 
import com.ibm.jms.JMSMessage;
 
import com.ibm.jms.JMSTextMessage;
 
import com.ibm.mq.jms.JMSC;
 
import com.ibm.mq.jms.MQQueue;
 
import com.ibm.mq.jms.MQQueueConnection;
 
import com.ibm.mq.jms.MQQueueConnectionFactory;
 
import com.ibm.mq.jms.MQQueueReceiver;
 
import com.ibm.mq.jms.MQQueueSender;
 
import com.ibm.mq.jms.MQQueueSession;
 
 
public class Send {
 
 
  public static void main(String[] args) {
 
 
   try {
 
      MQQueueConnectionFactory cf = new MQQueueConnectionFactory();
 
 
      // Config
 
      cf.setHostName("10.14.101.174");
 
      cf.setPort(1414);
 
      cf.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
 
      cf.setQueueManager("WQM");
 
      cf.setChannel("SYSTEM.ADMIN.SVRCONN");
 
    
 
    System.out.println("HERE  --- Right before MQQueueConnection \n");
 
 
      MQQueueConnection connection = (MQQueueConnection) cf.createQueueConnection();
 
    System.out.println("HERE  --- Right after MQQueueConnection  ");
 
   
 
 
      MQQueueSession    session    = (MQQueueSession)    connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
 
 
      MQQueue           queue      = (MQQueue)           session.createQueue("queue:///TEST");
 
 
      MQQueueSender     sender     = (MQQueueSender)     session.createSender(queue);
 
 
      MQQueueReceiver   receiver   = (MQQueueReceiver)   session.createReceiver(queue);      
 
    System.out.println("HERE  --- 4 \n  ");
 
      long uniqueNumber = System.currentTimeMillis() % 1000;
 
      JMSTextMessage message = (JMSTextMessage) session.createTextMessage("Msg:"+ uniqueNumber);
 
    System.out.println("HERE  --- 5  ");
 
      // Start the connection
 
      connection.start();
 
 
      sender.send(message);
 
      System.out.println("Sent message:\\n" + message);
 
 
      JMSMessage receivedMessage = (JMSMessage) receiver.receive(10000);
 
      System.out.println("\\nReceived message:\\n" + receivedMessage);
 
 
      sender.close();
 
      receiver.close();
 
      session.close();
 
      connection.close();
 
 
      System.out.println("\\nSUCCESS\\n");
 
    }
 
    catch (JMSException jmex) {
 
      System.out.println("JMS Exception" + jmex);
 
    }
 
    catch (Exception ex) {
 
 
      System.out.println("Std Exception" + ex);
 
    }
 
  }
 
} | 
   
 
 
 
I compile the program with warnings:
 
 
   
	| Code: | 
   
  
	C:\MQClient>"C:\Program Files (x86)\Java\jdk1.6.0_06\bin\"javac -Xlint:deprecati
 
on  -classpath jms.jar;com.ibm.mq.jar;dhbcore.jar;connector.jar;com.ibm.mq.jmqi.
 
jar;com.ibm.mqjms.jar;jms.jar Send.java
 
Send.java:6: warning: [deprecation] com.ibm.mq.jms.JMSC in com.ibm.mq.jms has be
 
en deprecated
 
import com.ibm.mq.jms.JMSC;
 
                     ^
 
Send.java:24: warning: [deprecation] com.ibm.mq.jms.JMSC in com.ibm.mq.jms has b
 
een deprecated
 
      cf.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
 
                          ^
 
2 warnings
 
 
C:\MQClient> | 
   
 
 
 
I get a problem when I invoke the program  (Notice there is not a linked list after the error)
 
 
   
	| Code: | 
   
  
	C:\MQClient>java -Djava.library.path="C:\Program Files (x86)\Java\jdk1.6.0_06\li
 
b" -cp ;com.ibm.mq.jar;com.ibm.mq.jmqi.jar;com.ibm.mqjms.jar";"C:\MQClient\conne
 
ctor.jar;dhbcore.jar;jms.jar Send
 
HERE  --- Right before MQQueueConnection
 
 
JMS Exceptioncom.ibm.msg.client.jms.DetailedJMSException: JMSFMQ6312: An excepti
 
on occurred in the Java(tm) MQI.
 
The Java(tm) MQI has thrown an exception describing the problem.
 
See the linked exception for further information.
 
 
C:\MQClient> | 
   
 
 
 
The code is failing on the following line:
 
 
   
	| Code: | 
   
  
	|     MQQueueConnection connection = (MQQueueConnection) cf.createQueueConnection(); | 
   
 
 
 
The -verbose option provides the following info
 
 
   
	| Code: | 
   
  
	class load: com.ibm.msg.client.jms.DetailedJMSException from: file:/C:/MQClient/
 
com.ibm.mqjms.jar
 
JMS Exceptioncom.ibm.msg.client.jms.DetailedJMSException: JMSFMQ6312: An excepti
 
on occurred in the Java(tm) MQI.
 
The Java(tm) MQI has thrown an exception describing the problem.
 
See the linked exception for further information.
 
class load: java/util/IdentityHashMap$1
 
class load: java/util/IdentityHashMap$IdentityHashMapIterator
 
class load: java/util/IdentityHashMap$1$1
 
class load: java/util/IdentityHashMap$IdentityHashMapEntry
 
class load: com/ibm/tools/attach/javaSE/NonBlockingFileLockManager
 
class load: java/nio/channels/ClosedChannelException
 
class load: java/util/LinkedHashMap$1
 
class load: java/util/LinkedHashMap$KeyIterator
 
 
C:\MQClient> | 
   
 
 
 
I checked the channel, it is easily accessed (I used SYSTEM.ADMIN.SRVCONN so I could test via the Explorer)
 
 
What should I do to diagnose and recover ? | 
			   
			 
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | Gideon | 
		  
		    
			  
				 Posted: Mon Mar 18, 2013 3:34 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		 
		
		   Chevalier
 
 Joined: 18 Aug 2009 Posts: 403
  
  | 
		  
		    
			  
				The Stack Trace contains:
 
 
   
	| Code: | 
   
  
	C:\MQClient>java -Djava.library.path="C:\Program Files (x86)\Java\jdk1.6.0_06\li
 
b" -cp ;com.ibm.mq.jar;com.ibm.mq.jmqi.jar;com.ibm.mqjms.jar";"C:\MQClient\conne
 
ctor.jar;dhbcore.jar;jms.jar Send
 
HERE  --- Right before MQQueueConnection
 
 
JMS Exceptioncom.ibm.msg.client.jms.DetailedJMSException: JMSFMQ6312: An excepti
 
on occurred in the Java(tm) MQI.
 
The Java(tm) MQI has thrown an exception describing the problem.
 
See the linked exception for further information.
 
com.ibm.msg.client.jms.DetailedJMSException: JMSFMQ6312: An exception occurred i
 
n the Java(tm) MQI.
 
The Java(tm) MQI has thrown an exception describing the problem.
 
See the linked exception for further information.
 
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 
 
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
 
orAccessorImpl.java:44)
 
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
 
onstructorAccessorImpl.java:39)
 
        at java.lang.reflect.Constructor.newInstance(Constructor.java:516)
 
        at com.ibm.msg.client.commonservices.j2se.NLSServices.createException(NL
 
SServices.java:319)
 
        at com.ibm.msg.client.commonservices.nls.NLSServices.createException(NLS
 
Services.java:233)
 
        at com.ibm.msg.client.wmq.factories.WMQConnectionFactory.createV7Provide
 
rConnection(WMQConnectionFactory.java:6863)
 
        at com.ibm.msg.client.wmq.factories.WMQConnectionFactory.createProviderC
 
onnection(WMQConnectionFactory.java:6254)
 
        at com.ibm.msg.client.jms.admin.JmsConnectionFactoryImpl.createConnectio
 
n(JmsConnectionFactoryImpl.java:285)
 
        at com.ibm.mq.jms.MQConnectionFactory.createCommonConnection(MQConnectio
 
nFactory.java:6189)
 
        at com.ibm.mq.jms.MQQueueConnectionFactory.createQueueConnection(MQQueue
 
ConnectionFactory.java:120)
 
        at Send.main(Send.java:30)
 
Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2195;AMQ9546: Error return cod
 
e received. [1=java.lang.reflect.InvocationTargetException[null],3=NativeConstru
 
ctorAccessorImpl.newInstance0]
 
        at com.ibm.mq.jmqi.JmqiEnvironment.processESESecurity(JmqiEnvironment.ja
 
va:1033)
 
        at com.ibm.mq.jmqi.JmqiEnvironment.getInstance(JmqiEnvironment.java:860)
 
 
        at com.ibm.mq.jmqi.JmqiEnvironment.getMQI(JmqiEnvironment.java:666)
 
        at com.ibm.msg.client.wmq.factories.WMQConnectionFactory.createV7Provide
 
rConnection(WMQConnectionFactory.java:6855)
 
        ... 5 more
 
Caused by: java.lang.reflect.InvocationTargetException
 
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 
 
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
 
orAccessorImpl.java:44)
 
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
 
onstructorAccessorImpl.java:39)
 
        at java.lang.reflect.Constructor.newInstance(Constructor.java:516)
 
        at com.ibm.mq.jmqi.JmqiEnvironment.processESESecurity(JmqiEnvironment.ja
 
va:940)
 
        ... 8 more
 
Caused by: java.lang.NoClassDefFoundError: com.ibm.mq.headers.MQDataException
 
        at java.lang.J9VMInternals.verifyImpl(Native Method)
 
        at java.lang.J9VMInternals.verify(J9VMInternals.java:72)
 
        at java.lang.J9VMInternals.initialize(J9VMInternals.java:134)
 
        at com.ibm.mq.ese.service.ServicesFactoryImpl.createPolicyService(Servic
 
esFactoryImpl.java:173)
 
        at com.ibm.mq.ese.jmqi.InterceptedJmqiImpl.createServices(InterceptedJmq
 
iImpl.java:227)
 
        at com.ibm.mq.ese.jmqi.InterceptedJmqiImpl.<init>(InterceptedJmqiImpl.ja
 
va:180)
 
        at com.ibm.mq.ese.jmqi.ESEJMQI.<init>(ESEJMQI.java:117)
 
        ... 13 more
 
Caused by: java.lang.ClassNotFoundException: com.ibm.mq.headers.MQDataException
 
        at java.net.URLClassLoader.findClass(URLClassLoader.java:421)
 
        at java.lang.ClassLoader.loadClass(ClassLoader.java:652)
 
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:346)
 
        at java.lang.ClassLoader.loadClass(ClassLoader.java:618)
 
        ... 20 more
 
 
C:\MQClient> | 
   
 
 | 
			   
			 
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | fjb_saper | 
		  
		    
			  
				 Posted: Mon Mar 18, 2013 7:15 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		 
		
		    Grand High Poobah
 
 Joined: 18 Nov 2003 Posts: 20768 Location: LI,NY 
  | 
		  
		    
			  
				you said that you're not a programmer. So keep your hands of programming or expect pain in direct intensity with your ignorance.
 
 
Look in the examples in the samples directory. If you don't find the directory update the installation and make sure the MQ SDK is installed.
 
 
Have fun   _________________ MQ & Broker admin | 
			   
			 
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | Gideon | 
		  
		    
			  
				 Posted: Tue Mar 19, 2013 11:19 am    Post subject:  | 
				     | 
			   
			 
		   | 
		 
		
		   Chevalier
 
 Joined: 18 Aug 2009 Posts: 403
  
  | 
		  
		    
			  
				Thanks for you post, very helpful
 
 
I reinstalled the WMQ Client for 7.5
 
 
I found the following program:
 
 
C:\Program Files (x86)\IBM\WebSphere MQ_1\tools\jms\samples\JmsProducer.java
 
 
So I have an excellent java program in which to modify
 
 
I did not find any .bat files showing how to compile this program
 
 
Where can I find documentation on how to compile and invoke the program  (what jars and DLL's I need, etc) 
 
 
Thanks | 
			   
			 
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | rekarm01 | 
		  
		    
			  
				 Posted: Wed Mar 20, 2013 1:27 am    Post subject: Re: Error invoking Java JMS program | 
				     | 
			   
			 
		   | 
		 
		
		   Grand Master
 
 Joined: 25 Jun 2008 Posts: 1415
  
  | 
		  
		    
			  
				
   
	| Gideon wrote: | 
   
  
	I compile the program with warnings:
 
 
   
	| Code: | 
   
  
	C:\MQClient>"C:\Program Files (x86)\Java\jdk1.6.0_06\bin\"javac -Xlint:deprecation  -classpath jms.jar;com.ibm.mq.jar;dhbcore.jar;connector.jar;com.ibm.mq.jmqi.jar;com.ibm.mqjms.jar;jms.jar Send.java
 
Send.java:6: warning: [deprecation] com.ibm.mq.jms.JMSC in com.ibm.mq.jms has been deprecated
 
import com.ibm.mq.jms.JMSC;
 
                     ^
 
Send.java:24: warning: [deprecation] com.ibm.mq.jms.JMSC in com.ibm.mq.jms has been deprecated
 
      cf.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
 
                          ^
 
2 warnings | 
   
 
 | 
   
 
 
Sometimes constants get moved to other packages, or renamed.  The documentation for MQConnectionFactory.setTransportType() lists the valid types. com.ibm.mq.jms.JMSC.MQJMS_TP_CLIENT_MQ_TCPIP is now com.ibm.msg.client.wmq.WMQConstants.WMQ_CM_CLIENT .
 
 
   
	| Gideon wrote: | 
   
  
	| I get a problem when I invoke the program  (Notice there is not a linked list after the error) | 
   
 
 
For that, the catch handler needs to explicitly call the J2EE JMSException.getLinkedException() method.  Fortunately, this is now the same as the J2SE Throwable.getCause() method, so the LinkedException is also available from the stack trace:
 
 
   
	| Gideon wrote: | 
   
  
	
   
	| Code: | 
   
  
	com.ibm.msg.client.jms.DetailedJMSException: JMSFMQ6312: An exception occurred in the Java(tm) MQI.
 
Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2195;AMQ9546: Error return code received. [1=java.lang.reflect.InvocationTargetException[null],3=NativeConstructorAccessorImpl.newInstance0]
 
Caused by: java.lang.reflect.InvocationTargetException
 
Caused by: java.lang.NoClassDefFoundError: com.ibm.mq.headers.MQDataException
 
Caused by: java.lang.ClassNotFoundException: com.ibm.mq.headers.MQDataException | 
   
 
 | 
   
 
 
The AMQ9546 and RC=2195 messages don't seem to add much information, but it looks like the class definition for com.ibm.mq.headers.MQDataException is missing.  The most likely cause for that is the omission of the com.ibm.mq.headers.jar from the classpath. | 
			   
			 
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | 
		    
		   | 
		 
	   
	 | 
   
 
  
	     | 
	 | 
	Page 1 of 1 | 
   
 
 
 
  
  	
	  
		
		  
 
  | 
		  You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
  | 
  		 
	   
	 | 
   
 
  	 | 
	  |