Note that there are some explanatory texts on larger screens.

plurals
  1. POError running simple jar with MQ classes for Java
    primarykey
    data
    text
    <p>I'm very beginner of <code>Websphere MQ classes for Java</code> programming.<br> I've decided to follow this way to write a small application able to connect and read messages from a queue through TCP/IP.</p> <p>following this guide: <a href="http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/index.jsp?topic=%2Fcom.ibm.mq.csqzaw.doc%2Fja10410_.htm" rel="nofollow">http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/index.jsp?topic=%2Fcom.ibm.mq.csqzaw.doc%2Fja10410_.htm</a></p> <p>At point 4 it is suggested to test <code>Websphere Client</code> installation (Version: 7.0.1.8) on windows command prompt using:<br> <code>java -Djava.library.path=library_path MQIVP</code><br> where 'library_path' for me is "C:\Program Files\IBM\WebSphere MQ\java\lib"</p> <p>The application runs and I have proceeded writing a simple program with <code>Eclipse IDE</code> here the code:</p> <pre><code>import com.ibm.mq.MQEnvironment; public class MQtestMain { public static void main(String[] args) { System.out.println("main"); new MQtestMain(); } public MQtestMain(){ System.out.println("MQtestMain"); MQEnvironment.hostname = "my.host.name"; MQEnvironment.channel = "my.channel"; MQEnvironment.port = 1414; } } </code></pre> <p>It has nothing to do but it is just a test to be sure that everything is correctly set.</p> <p>I have set a custom library with both 'com.ibm.mq.jar' and 'com.ibm.mq.jmqi.jar' from "C:\Program Files\IBM\WebSphere MQ\java\lib" and no error are reported at compile time.</p> <p>Running the application from <code>Eclipse</code> it correctly prints out "main" and "MQtestMain" on console.</p> <p>Therefore I have proceeded to export it: File > Export > Runnable Jar <br> setting 'Library handling' to 'Package required libraries into generated JAR'</p> <p>Unfortunately if I run the program from windows command prompt: <code>java -jar MQtest.jar</code> here the result:</p> <pre><code>main MQtestMain Exception in thread "main" java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa der.java:58) Caused by: java.lang.NoClassDefFoundError: javax/resource/ResourceException at com.ibm.mq.MQEnvironment.&lt;clinit&gt;(MQEnvironment.java:576) at MQtestMain.&lt;init&gt;(MQtestMain.java:21) at MQtestMain.main(MQtestMain.java:14) ... 5 more Caused by: java.lang.ClassNotFoundException: javax.resource.ResourceException at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 8 more </code></pre> <p>First and second line are correct but I really don't understand the following errors</p> <hr> <p><strong>update:</strong></p> <p>I try to give you more information: <br> As I've said running the application from its main <code>class</code> file there are no problems, while execute it from the <code>jar</code> file it seems not able to find the IBM libraries.<br> I have created a personal library in <code>eclipse</code> named "MQ classes for Java" containig the two jar packages used by this application.<br> here the content of the project <code>.classpath</code> file:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;classpath&gt; &lt;classpathentry kind="src" path="src"/&gt; &lt;classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/&gt; &lt;classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/MQ classes for Java"/&gt; &lt;classpathentry kind="output" path="bin"/&gt; &lt;/classpath&gt; </code></pre> <p>Is there a way to link the correct libraries to the runnable jar in order to launch it form every machine with WMQ Client installed?</p> <hr> <p><strong>Solution:</strong></p> <p>The errors, due to some dependencies not found, have been solved including <strong>all</strong> the <code>IBM classes for Java</code> <code>jar</code> files into the <code>WMQ Client</code> folder instalation ("C:\Program Files\IBM\WebSphere MQ\java\lib")</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload