Author |
Message
|
vasilev |
Posted: Sun Nov 12, 2023 6:43 am Post subject: problem with MQQueueManager and org.json.JSONException |
|
|
Acolyte
Joined: 31 Oct 2014 Posts: 71 Location: Germany
|
Hello,
I am using google gson to parse the input parameters for qmanager.
I have removed the not interesting part of the code. When I run it I get:
Code: |
Exception in thread "main" java.lang.NoClassDefFoundError: org/json/JSONException
at ....main(test.java:6) -> line where MQQueueManager qmgr = new MQQueueManager(pqm); is.
Caused by: java.lang.ClassNotFoundException: org.json.JSONException
|
All is fine if I add json library. The question is why I have to add it?
Is there any dependency for the com.ibm.mq with org.json ?
com.ibm.mq.allclient -> 9.3.4.0 - p934-L230927
gson-2.10.1
Code: |
import java.util.Base64;
import com.ibm.mq.MQEnvironment;
import com.ibm.mq.MQQueueManager;
import com.ibm.mq.headers.pcf.PCFMessageAgent;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
public static void main(String[] args) throws Exception {
Gson gson = new GsonBuilder().serializeNulls().create();
JsonObject jsonargs = gson.fromJson("{'qmanager':'test'}", JsonObject.class);
String pqm = jsonargs.getAsJsonObject().get("qmanager").getAsString();
try {
MQQueueManager qmgr = new MQQueueManager(pqm);
} catch (Exception e) {
System.out.println(e);
}
} |
Thank you _________________ Regards
V.Vasilev |
|
Back to top |
|
|
hughson |
Posted: Mon Nov 13, 2023 1:51 am Post subject: |
|
|
Padawan
Joined: 09 May 2013 Posts: 1948 Location: Bay of Plenty, New Zealand
|
I am not aware of any JSON dependency in the MQ classes. What makes you suspect the MQ classes rather than the JSON related part of your code?
If you remove the call to MQQueueManager, do you still see the error?
Cheers,
Morag _________________ Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
Get your IBM MQ training here!
MQGem Software |
|
Back to top |
|
|
vasilev |
Posted: Mon Nov 13, 2023 2:32 am Post subject: |
|
|
Acolyte
Joined: 31 Oct 2014 Posts: 71 Location: Germany
|
hi Morag,
thanks for the reply ..
I have created new project because I thought there is some dependency in the previous project. Then deleted everything just left the line with new qm:
Code: |
import com.ibm.mq.MQException;
import com.ibm.mq.MQQueueManager;
public class test{
public static void main(String args[]) throws Exception {
try {
MQQueueManager qmgr = new MQQueueManager("TEST"); -> if i comment this line - no problem.
System.out.println("test");
} catch (MQException ex) {
System.out.println("A WebSphere MQ Error occured : Completion Code " + ex.completionCode
+ " Reason Code " + ex.reasonCode);
}
catch (Exception e) {
System.out.println(e);
}
}
}
|
the error:
Code: |
Exception in thread "main" java.lang.NoClassDefFoundError: org/json/JSONException
at test.main(test.java:11)
Caused by: java.lang.ClassNotFoundException: org.json.JSONException
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
... 1 more
|
_________________ Regards
V.Vasilev |
|
Back to top |
|
|
vasilev |
Posted: Mon Nov 13, 2023 2:57 am Post subject: |
|
|
Acolyte
Joined: 31 Oct 2014 Posts: 71 Location: Germany
|
update:
this is the last version of the com.ibm.mq.allclient that has no such problem:
https://repo1.maven.org/maven2/com/ibm/mq/com.ibm.mq.allclient/9.2.3.0/
from 9.2.4.0 -> Json exception.
till 9.2.3.0 -> normal exception : Completion Code 2 Reason Code 2495
it is written Compile Dependencies (4) -> org.json but till 9.2.3 seems it is not mandatory _________________ Regards
V.Vasilev |
|
Back to top |
|
|
fjb_saper |
Posted: Mon Nov 13, 2023 10:41 am Post subject: |
|
|
Grand High Poobah
Joined: 18 Nov 2003 Posts: 20729 Location: LI,NY
|
Are you sure you're not trying to use a JSON CCDT behind the covers to access the queue manager? That would mandate the user of the json.jar. _________________ MQ & Broker admin |
|
Back to top |
|
|
vasilev |
Posted: Mon Nov 13, 2023 11:37 pm Post subject: |
|
|
Acolyte
Joined: 31 Oct 2014 Posts: 71 Location: Germany
|
thank you for the hint !
I am using my own json as input parameters:
Code: |
{"type":"READ","function":"QAGE","host":"...","qmgr":"...","port":"1414","chl":"...","ssl":"no","conntype":"client","alertnum":"2"} |
I saw that json CCDT has "channel" as key, I have changed to "chl" but still the same error.
Even if I remove the json as input string and write only test (so no json) .. the same. _________________ Regards
V.Vasilev |
|
Back to top |
|
|
RogerLacroix |
Posted: Thu Nov 16, 2023 4:16 pm Post subject: Re: problem with MQQueueManager and org.json.JSONException |
|
|
Jedi Knight
Joined: 15 May 2001 Posts: 3258 Location: London, ON Canada
|
vasilev wrote: |
All is fine if I add json library. The question is why I have to add it?
Is there any dependency for the com.ibm.mq with org.json ? |
I discovered recently that IBM has changed something in the MQ/Java Client Library that requires org.json.jar file to be included.
I haven't seen anything about it in the MQ Knowledge Center but definitely something changed.
later
Roger _________________ Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter |
|
Back to top |
|
|
|