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 » PCFMessageAgent instance not getting created.

Post new topic  Reply to topic
 PCFMessageAgent instance not getting created. « View previous topic :: View next topic » 
Author Message
aarjavshah
PostPosted: Mon Oct 26, 2015 3:54 am    Post subject: PCFMessageAgent instance not getting created. Reply with quote

Newbie

Joined: 26 Oct 2015
Posts: 8

I am trying to retrieve the channel status of a remote Queue Manager using PCFMessageAgent. While I am trying to create the instance of it I am getting the below error.
Code:

Exception in thread "main" java.lang.NoClassDefFoundError: com/ibm/mq/internal/MQCommonServices
   at com.ibm.mq.pcf.PCFAgent.getJmqiEnv(PCFAgent.java:124)
   at com.ibm.mq.pcf.PCFAgent.<init>(PCFAgent.java:132)
   at com.ibm.mq.pcf.PCFAgent.<init>(PCFAgent.java:146)
   at com.ibm.mq.pcf.PCFMessageAgent.<init>(PCFMessageAgent.java:126)
   at com.sample.model.Test2.main(Test2.java:77)
Caused by: java.lang.ClassNotFoundException: com.ibm.mq.internal.MQCommonServices
   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 sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 5 more




For the reference I am putting the code here.

Code:

      MQEnvironment.hostname = hostname;           
       MQEnvironment.port  = port;           
       MQEnvironment.channel = channel;
       MQEnvironment.properties.put(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_CLIENT);
        MQQueueManager qMgr=null;
      PCFMessageAgent agent =null;
             try {
            qMgr = new MQQueueManager(qManager);
            agent = new PCFMessageAgent (qMgr);
            mes= new PCFMessage(CMQCFC.MQCMD_INQUIRE_CHANNEL_STATUS);
            mes.addParameter(CMQCFC.MQCACH_CHANNEL_NAME, "*");
            mes.addParameter(CMQCFC.MQIACH_CHANNEL_TYPE, CMQXC.MQCHT_ALL);
            mes.addParameter(CMQCFC.MQIACH_CHANNEL_INSTANCE_ATTRS,
                                 new int []
                                 {
                                    CMQCFC.MQCACH_CHANNEL_NAME,
                                    CMQCFC.MQCACH_CONNECTION_NAME,
                                    CMQCFC.MQIACH_CHANNEL_STATUS,
                                    CMQCFC.MQIACH_CHANNEL_SUBSTATE,
                                    CMQCFC.MQIACH_MSGS,
                                    CMQCFC.MQCACH_LAST_MSG_DATE,
                                    CMQCFC.MQCACH_LAST_MSG_TIME,
                                    CMQCFC.MQCACH_CHANNEL_START_DATE,
                                    CMQCFC.MQCACH_CHANNEL_START_TIME,
                                    CMQCFC.MQIACH_BYTES_SENT,
                                    CMQCFC.MQIACH_BYTES_RECEIVED,
                                    CMQCFC.MQIACH_BUFFERS_SENT,
                                    CMQCFC.MQIACH_BUFFERS_RECEIVED,
                                    CMQCFC.MQIACH_MCA_STATUS,
                                    CMQCFC.MQCACH_MCA_JOB_NAME,
                                    CMQCFC.MQCACH_MCA_USER_ID
                                 } );
                     res = agent.send(mes);
                 }
                 catch(Exception e){
                 e.printStackTrace();
                 }



I have included
com.ibm.mq.jar
com.ibm.mq.headers.jar
com.ibm.mq.commonservices.jar
com.ibm.mq.jmqi.jar
com.ibm.mq.pcf.jar
com.ibm.mqjms.jar
connector.jar
dhbcore.jar
fscontext.jar
providerutil.jar


Moreover, I have tried to create the instance using other constructors of PCFMessageAgent. It is throwing same exception every time. Note: I am able to connect to queue manager and do operations like get or put messages to the queues etc.

Can anyone tell me what I might have missed here?
Has anyone else has faced the same problem?
Please Help.
Thanks in advance.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Oct 26, 2015 5:41 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

This is clearly a problem with your classpath. Should be relatively easy to solve...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
aarjavshah
PostPosted: Mon Oct 26, 2015 10:29 pm    Post subject: Reply with quote

Newbie

Joined: 26 Oct 2015
Posts: 8

I have already set the classpath to MQ lib. What else can I do to fix this?
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Oct 27, 2015 7:16 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

aarjavshah wrote:
I have already set the classpath to MQ lib. What else can I do to fix this?

That may well be your problem.
Try setting the classpath to (depending on your environment)
Code:
set classpath=%MQ_JAVA_INSTALL_PATH%\lib\*;%classpath%
export CLASSPATH=${MQ_JAVA_INSTALL_PATH}/lib/*:${CLASSPATH}

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
aarjavshah
PostPosted: Wed Oct 28, 2015 4:18 am    Post subject: Reply with quote

Newbie

Joined: 26 Oct 2015
Posts: 8

The same was set in my classpath.

Anyways, I have solved the issue.

This is NOT a classpath issue. This was a problem with JVM version. The version of JVM of my eclipse was not compatible with MQ APIs.
I created the project in IIB 9.0 toolkit and ran it on that JVM. It is working fine now.

Thank you for your help.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Oct 28, 2015 4:29 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

aarjavshah wrote:
The same was set in my classpath.

Anyways, I have solved the issue.

This is NOT a classpath issue. This was a problem with JVM version. The version of JVM of my eclipse was not compatible with MQ APIs.
I created the project in IIB 9.0 toolkit and ran it on that JVM. It is working fine now.

Thank you for your help.


Usually a Class Not Found is a classpath issue and not a JVM issue.
Remember when you use -jar to add your classpath to the -Djava.ext.dirs value.
JVM issues usually manifest themselves as a wrong version number for the class... However there are some Class not found issues when using a non IBM JVM and trying to do JMS with SSL in some of the early 7.5.0.x versions.

However those usually point to a different class.

As you are talking about eclipse it is more likely that you missed to add the MQ library to your classpath. I always create a library in eclipse for all my MQ jars. This way I do not mix jars from different MQ versions which is a big no no.
You are of course aware that you can use a higher JVM version than the default in your eclipse? See installed JREs. Whith a somewhat recent eclipse this should not be a problem as you configure your project environment as to the level of JVM to be used...

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
aarjavshah
PostPosted: Wed Oct 28, 2015 4:38 am    Post subject: Reply with quote

Newbie

Joined: 26 Oct 2015
Posts: 8

Yes, it was non IBM JVM. So, the thing you pointed out should be true.

It was showing com.ibm.mq.internal.MQCommonServices class not found
It wasn't even a class, it was the package.

com.ibm.mq.internal.MQCommonServices.jmqiEnv this was the class at the line 124 which was there in the error and it was pointing to com.ibm.mq.jmqi.JmqiEnvironment.

And creating a library for a particular MQ version is a good suggestion instead of all separate jars, I'll follow that one.

Thanks.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » PCFMessageAgent instance not getting created.
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.