ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » problem with MQQueueManager and org.json.JSONException

Post new topic  Reply to topic
 problem with MQQueueManager and org.json.JSONException « View previous topic :: View next topic » 
Author Message
vasilev
PostPosted: Sun Nov 12, 2023 6:43 am    Post subject: problem with MQQueueManager and org.json.JSONException Reply with quote

Acolyte

Joined: 31 Oct 2014
Posts: 58
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
View user's profile Send private message Visit poster's website
hughson
PostPosted: Mon Nov 13, 2023 1:51 am    Post subject: Reply with quote

Padawan

Joined: 09 May 2013
Posts: 1916
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
View user's profile Send private message Visit poster's website
vasilev
PostPosted: Mon Nov 13, 2023 2:32 am    Post subject: Reply with quote

Acolyte

Joined: 31 Oct 2014
Posts: 58
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
View user's profile Send private message Visit poster's website
vasilev
PostPosted: Mon Nov 13, 2023 2:57 am    Post subject: Reply with quote

Acolyte

Joined: 31 Oct 2014
Posts: 58
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
View user's profile Send private message Visit poster's website
fjb_saper
PostPosted: Mon Nov 13, 2023 10:41 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
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
View user's profile Send private message Send e-mail
vasilev
PostPosted: Mon Nov 13, 2023 11:37 pm    Post subject: Reply with quote

Acolyte

Joined: 31 Oct 2014
Posts: 58
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
View user's profile Send private message Visit poster's website
RogerLacroix
PostPosted: Thu Nov 16, 2023 4:16 pm    Post subject: Re: problem with MQQueueManager and org.json.JSONException Reply with quote

Jedi Knight

Joined: 15 May 2001
Posts: 3253
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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » problem with MQQueueManager and org.json.JSONException
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.