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 » help me to run my first program in MQ

Post new topic  Reply to topic Goto page 1, 2  Next
 help me to run my first program in MQ « View previous topic :: View next topic » 
Author Message
mailtosathiyan@gmail.com
PostPosted: Tue Aug 02, 2005 7:59 pm    Post subject: help me to run my first program in MQ Reply with quote

Novice

Joined: 02 Aug 2005
Posts: 13

Hi
I m very new to MQ, this is my first program,

And I m using
IDE -rational application architect
app. server - was6 -express
MQ- version 6
and my Queue Manger name -QM1
Queue name is - Q1
hostname -sathya


//////////////////////////////////////////////////code here/////////////
package test;
import com.ibm.mq.MQC;
import com.ibm.mq.MQEnvironment;
import com.ibm.mq.MQException;
import com.ibm.mq.MQMessage;
import com.ibm.mq.MQPutMessageOptions;
import com.ibm.mq.MQQueue;
import com.ibm.mq.MQQueueManager;
public class test1
{
private String qManager = "QM1";
private MQQueueManager qMgr;
public static void main(String args[]) {
new test1();
}
public test1() {
try {
java.util.Hashtable properties;
MQEnvironment.hostname = "sathya";
MQEnvironment.channel = "SYSTEM.DEF.SVRCONN";

MQEnvironment.properties.put(MQC.TRANSPORT_PROPERTY,MQC.TRANSPORT_MQSERIES_BINDINGS);
qMgr = new MQQueueManager(qManager);
System.out.println("Connection with "+ qManager + "is opened !");
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF |
MQC.MQOO_OUTPUT;
MQQueue ql_test =
qMgr.accessQueue("Q1",openOptions,null,null,null);
MQMessage hello_world = new MQMessage();
hello_world.writeUTF("Hello World !!!");
MQPutMessageOptions pmo = new
MQPutMessageOptions();
ql_test.put(hello_world,pmo);
int Key;
System.out.println("Press Enter !!!");
Key = System.in.read();
ql_test.close();
qMgr.disconnect();
System.out.println("Disconnected !");
}
catch (MQException ex) {
System.out.println("CC: " + ex.completionCode + "RC: "+ ex.reasonCode);
}
catch (java.io.IOException ex) {
System.out.println("IO Error: "+ex);
}
}
}

//code end//////////////////////
**********error displayed********
Exception in thread "main" java.lang.NoSuchFieldError: msgToken
at com.ibm.mq.server.MQSESSION.init_conversion(Native Method)
at com.ibm.mq.server.MQSESSION.<clinit>(MQSESSION.java:254)
at com.ibm.mq.MQSESSIONServer.getMQSESSION(MQSESSIONServer.java:6
at com.ibm.mq.MQSESSION.getSession(MQSESSION.java:493)
at com.ibm.mq.MQManagedConnectionJ11.<init>(MQManagedConnectionJ11.java:155)
at com.ibm.mq.MQBindingsManagedConnectionFactoryJ11._createManagedConnection(MQBindingsManagedConnectionFactoryJ11.java:153)
at com.ibm.mq.MQBindingsManagedConnectionFactoryJ11.createManagedConnection(MQBindingsManagedConnectionFactoryJ11.java:189)
at com.ibm.mq.StoredManagedConnection.<init>(StoredManagedConnection.java:80)
at com.ibm.mq.MQSimpleConnectionManager.allocateConnection(MQSimpleConnectionManager.java:171)
at com.ibm.mq.MQQueueManager.obtainBaseMQQueueManager(MQQueueManager.java:754)
at com.ibm.mq.MQQueueManager.construct(MQQueueManager.java:688)
at com.ibm.mq.MQQueueManager.<init>(MQQueueManager.java:417)
at test.test1.<init>(test1.java:30)
at test.test1.main(test1.java:21)

i m getting the same error for all the application related to MQ series . can any one tell what’s this problem.
Is it any problem with configuration?
Is it because embedded messaging?
Can any one help me please?!
Thanks
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Aug 03, 2005 11:47 am    Post subject: Reply with quote

Grand High Poobah

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

If you are using WAS6 is there any specific reason you are not using the message bus or JMS ? They would be more appropriate for your environment.

Back to top
View user's profile Send private message Send e-mail
mailtosathiyan@gmail.com
PostPosted: Wed Aug 03, 2005 8:42 pm    Post subject: problem solved Reply with quote

Novice

Joined: 02 Aug 2005
Posts: 13

hi
i have to refer mq, mqjms and jms jar on MQ6 only not with WAS6
that's it all works fine
thanks and regards
sathiya
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Aug 04, 2005 2:30 am    Post subject: Re: problem solved Reply with quote

Grand High Poobah

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

mailtosathiyan@gmail.com wrote:
hi
i have to refer mq, mqjms and jms jar on MQ6 only not with WAS6
that's it all works fine
thanks and regards
sathiya


It still does not answer my question ....
Back to top
View user's profile Send private message Send e-mail
mailtosathiyan@gmail.com
PostPosted: Thu Aug 04, 2005 3:33 am    Post subject: i m not getting it -since i m very new to MQ Reply with quote

Novice

Joined: 02 Aug 2005
Posts: 13

can u explain me messgae bus and etc in detail, i very keen to know about all.
please give me details about how to use those?

thanks and regards
sathiya
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Aug 04, 2005 11:51 am    Post subject: Reply with quote

Grand High Poobah

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

Check out the documentation in WAS 6.0 (IBM Redbooks)
As well check out the sun website for keyword JMS.
http://java.sun.com

Enjoy
Back to top
View user's profile Send private message Send e-mail
mailtosathiyan@gmail.com
PostPosted: Thu Aug 04, 2005 10:01 pm    Post subject: Reply with quote

Novice

Joined: 02 Aug 2005
Posts: 13

Hi
Currently I m practicing with windows environment with mq and jms
but in my real work
we have to send the data using mqclient from windows machine to the as400/iseries to interact with Cobol programs
is still possible without mqseries?
Please guide me

Thanks and regards
sathiya
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Fri Aug 05, 2005 4:07 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

If you're trying to talk to a non-java destination, then using JMS or the WAS6 message bus is not the right choice.

So use MQ the way you have been.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Aug 05, 2005 11:12 am    Post subject: Reply with quote

Grand High Poobah

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

jeff,

We use JMS all the time. We just specify
"queue:///myqueue?targetClient=1" when we define the queues...
or targetclient=MQ in jndi...

Works fine for us.

Thanks
Back to top
View user's profile Send private message Send e-mail
vennela
PostPosted: Fri Aug 05, 2005 11:34 am    Post subject: Reply with quote

Jedi Knight

Joined: 11 Aug 2002
Posts: 4055
Location: Hyderabad, India

There are quite a few changes in the MQ Java implementation in MQv6.

For example MQMessage class.
Previously MQMessage.messageId() is now MQMD.messageId()

I think he is getting one of those problems.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mailtosathiyan@gmail.com
PostPosted: Thu Aug 18, 2005 2:52 am    Post subject: problem with jndi options with sample application Reply with quote

Novice

Joined: 02 Aug 2005
Posts: 13

hi all
when i run the sample( PTPSample01.java) with the following options
(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
(Context.PROVIDER_URL, "iiop://localhost:2809");

getting the error like this
Exception in thread "main" java.lang.NoClassDefFoundError
at com.ibm.ejs.oa.EJSORBImpl.class$(EJSORBImpl.java:171)
at com.ibm.ejs.oa.EJSORBImpl.initializeORB(EJSORBImpl.java:171)
at com.ibm.ejs.oa.EJSClientORBImpl.<init>(EJSClientORBImpl.java:97)
at com.ibm.ejs.oa.EJSClientORBImpl.<init>(EJSClientORBImpl.java:73)
at com.ibm.ejs.oa.EJSORB.init(EJSORB.java:386)
at com.ibm.ws.naming.util.Helpers.getOrb(Helpers.java:285)
at com.ibm.ws.naming.util.WsnInitCtxFactory.getInitialContextInternal(WsnInitCtxFactory.java:373)
at com.ibm.ws.naming.util.WsnInitCtx.getContext(WsnInitCtx.java:112)
at com.ibm.ws.naming.util.WsnInitCtx.getContextIfNull(WsnInitCtx.java:422)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:143)
at javax.naming.InitialContext.lookup(InitialContext.java:361)
at test1.PTPSample01.getConnectionFactoryFromJNDI(PTPSample01.java:385)
at test1.PTPSample01.main(PTPSample01.java:170)
Caused by: java.lang.ClassNotFoundException: com.ibm.ws.orb.GlobalORBFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:375)
at java.lang.ClassLoader.loadClass(ClassLoader.java:562)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:442)
at java.lang.ClassLoader.loadClass(ClassLoader.java:494)
at java.lang.Class.forName1(Native Method)
at java.lang.Class.forName(Class.java:180)
... 13 more
and i have added following jars
com.ibm.mqjms.jar
com.ibm.mq.jar
jms.jar
namingclient.jar
naming.jar
ecutils.jar
wssec.jar
sas.jar
lmproxy.jar
ras.jar
emf.jar
namingserver.jar
bootstarp.jar
wsexception.jar
can one please tell me what r other things to be done?
Back to top
View user's profile Send private message
vennela
PostPosted: Thu Aug 18, 2005 8:26 am    Post subject: Reply with quote

Jedi Knight

Joined: 11 Aug 2002
Posts: 4055
Location: Hyderabad, India

Why do you want to store JNDI definitions in WAS to run a standalone java program?
Use FSContext or LDAP instead.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
jefflowrey
PostPosted: Thu Aug 18, 2005 8:30 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

It sounds like you probably need to install the WAS J2EE client, and run your code in that.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
mailtosathiyan@gmail.com
PostPosted: Thu Aug 18, 2005 9:47 pm    Post subject: tell me how to run code with JNDI? Reply with quote

Novice

Joined: 02 Aug 2005
Posts: 13

hi
i want to run the code using jndi and not with LDAP or etc
i m going to use WAS 6 and AS400 and MQ6(client)
currently i m working on windows version (just for practice)
can any one please tell me how to use this option
Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
(Context.PROVIDER_URL, "iiop://localhost:2809");

regards
sathiya
Back to top
View user's profile Send private message
mailtosathiyan@gmail.com
PostPosted: Thu Aug 18, 2005 9:55 pm    Post subject: any tell me how to create QCF and Queue? Reply with quote

Novice

Joined: 02 Aug 2005
Posts: 13

in this line i m getting error whether it's LDAP or JNDI or etc.
i think this is the only problem
factory = (QueueConnectionFactory)ctx.lookup( name );
how to create this QCF and Q?

regards
sathiya
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » IBM MQ Java / JMS » help me to run my first program in MQ
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.