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 » jndi problem

Post new topic  Reply to topic Goto page 1, 2  Next
 jndi problem « View previous topic :: View next topic » 
Author Message
pvsp
PostPosted: Mon Feb 25, 2008 6:38 am    Post subject: jndi problem Reply with quote

Apprentice

Joined: 17 Feb 2008
Posts: 36
Location: Warsaw, PL

Hi,
I'm reading an article about jndi and mq (http://www.ibm.com/developerworks/websphere/techjournal/0502_woolf/0502_woolf.html) and I have some problems with it.
I have downloaded the com.ibm.mq.pcf-6.0.3.jar and mqcontext.jar and next I set my classpath as it is written in article.
I uncommented JMSAdmin like below:
INITIAL_CONTEXT_FACTORY=com.sun.jndi.ldap.LdapCtxFactory
#INITIAL_CONTEXT_FACTORY=com.sun.jndi.fscontext.RefFSContextFactory
#INITIAL_CONTEXT_FACTORY=com.ibm.ejs.ns.jndi.CNInitialContextFactory
INITIAL_CONTEXT_FACTORY=com.ibm.websphere.naming.WsnInitialContextFactory
#
# The following line specifies the URL of the service provider's initial
# context. It currently refers to an LDAP root context. Examples of a
# file system URL and WebSphere's JNDI namespace are also shown, commented
# out.
#
#PROVIDER_URL=ldap://polaris/o=ibm,c=us
#PROVIDER_URL=file:/C:/JNDI-Directory
PROVIDER_URL=iiop://localhost:1414/

but when I try to run JMSAdmin.bat I always get the error "Class specyfied by INITIAL_CONTEXT_fACTORY not found in CLASSPATH".

In conclusion, I'm looking for a way to connect my java client application using jndi, but now I have a problem with the simple JMSAdmin app.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Mon Feb 25, 2008 6:49 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

So you provided two different INITIAL_CONTEXTs.

This isn't going to help much.

Secondly, one of those INITIAL_CONTEXTS, the com.ibm.websphere.naming.WsnInitialContextFactory - requires that your app run under a shell that has the full WAS App client profile or full WAS Server profile.

So that's not likely to help much either.

Use the com.sun.jndi.fscontext.RefFSContextFactory
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
pvsp
PostPosted: Mon Feb 25, 2008 6:52 am    Post subject: Reply with quote

Apprentice

Joined: 17 Feb 2008
Posts: 36
Location: Warsaw, PL

OK, I set JMSAdmin.conf

INITIAL_CONTEXT_FACTORY=com.ibm.mq.jms.context.WMQInitialContextFactory
PROVIDER_URL=localhost:1414/SYSTEM.DEF.SVRCONN

and it works
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Mon Feb 25, 2008 7:00 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

That's a really bad context to use, IMHO.

You've now tightly coupled your JNDI definitions to your MQ definitions.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
pvsp
PostPosted: Mon Feb 25, 2008 7:42 am    Post subject: Reply with quote

Apprentice

Joined: 17 Feb 2008
Posts: 36
Location: Warsaw, PL

I understand you suggest using com.sun.jndi.fscontext.RefFSContextFactory ?
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Mon Feb 25, 2008 7:50 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

I do suggest using the file system context.

Unless your code is running in a JEE container (app server or client), then you should use the App Server JNDI context.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
pvsp
PostPosted: Mon Feb 25, 2008 7:57 am    Post subject: Reply with quote

Apprentice

Joined: 17 Feb 2008
Posts: 36
Location: Warsaw, PL

I have to create standalone java app
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Feb 25, 2008 2:55 pm    Post subject: Reply with quote

Grand High Poobah

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

pvsp wrote:
I have to create standalone java app

Use the file context. It is easy to use and very stable.
Just remember the caveat on using subcontexts... it is mentioned in the documentation... see using java manual...

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
pvsp
PostPosted: Tue Feb 26, 2008 12:48 am    Post subject: Reply with quote

Apprentice

Joined: 17 Feb 2008
Posts: 36
Location: Warsaw, PL

ok, I established connection between my app and mq. Next I wrote the source:

Context context = new InitialContext(env);

MQQueueConnectionFactory factory = new MQQueueConnectionFactory();
factory.setQueueManager("QM_ORANGE");

MQQueueConnection connection = (MQQueueConnection)factory.createQueueConnection();

QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);

MQQueue ioQueue=(MQQueue)session.createQueue( "Q2" );

QueueSender queueSender = session.createSender(ioQueue);
TextMessage outMessage = session.createTextMessage();
outMessage.setText("test msg");
queueSender.send(outMessage);



QueueReceiver queueReceiver = session.createReceiver(ioQueue);
TextMessage inMessage = (TextMessage)queueReceiver.receive();
System.out.println(inMessage.getText());

and I have two questions.

1. I sent 'text msg' to Q2 and when I try to browse I see the RFH instead of 'text msg' in Message Data, Is it correct ?

2. The part of code responsible for receiving do nothing, why ?
Back to top
View user's profile Send private message
JLRowe
PostPosted: Tue Feb 26, 2008 2:37 am    Post subject: Reply with quote

Yatiri

Joined: 25 May 2002
Posts: 664
Location: South East London

Your code is using the MQ specific JMS classes, the whole point of using JNDI is that your code is not tied to a specific JMS provider.

e.g.

Code:
QueueConnectionFactory qcf = initialContext.lookup("my_MQ_QCF")


This way you avoid coding to a specific JMS provider.
Back to top
View user's profile Send private message Send e-mail
pvsp
PostPosted: Tue Feb 26, 2008 2:48 am    Post subject: Reply with quote

Apprentice

Joined: 17 Feb 2008
Posts: 36
Location: Warsaw, PL

Ok, I'll change my code but how about my two questions ?
Back to top
View user's profile Send private message
Vitor
PostPosted: Tue Feb 26, 2008 2:53 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

pvsp wrote:
Ok, I'll change my code but how about my two questions ?


1. Yes

2. It's not working.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
pvsp
PostPosted: Tue Feb 26, 2008 3:09 am    Post subject: Reply with quote

Apprentice

Joined: 17 Feb 2008
Posts: 36
Location: Warsaw, PL

Vitor wrote:
pvsp wrote:
Ok, I'll change my code but how about my two questions ?


1. Yes

2. It's not working.


Ad1.
Is it a good way to send MQHRF2 message. Maybe I should look for a possibility to change taht format from MQHRF2 to MQSTR ?

Ad2.
I know, but could you tell me why ? This part of code is from IBM WebSphere MQ using Java book, so I have no idea what is wrong :/
Back to top
View user's profile Send private message
Vitor
PostPosted: Tue Feb 26, 2008 3:17 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

pvsp wrote:
Ad1.
Is it a good way to send MQHRF2 message. Maybe I should look for a possibility to change taht format from MQHRF2 to MQSTR ?


Either you want to send a message with an RFH2 header (because you're using JMS) or you don't (because you're not). Decide which it is and look up target clients. Myself, I think you want that header.

pvsp wrote:
Ad2.
I know, but could you tell me why ? This part of code is from IBM WebSphere MQ using Java book, so I have no idea what is wrong :/


There are any number of possible reason. A good bit of problem investigation and resolution (with some linked exceptions) will see you through it.

The reasons may not be code related.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Feb 26, 2008 3:29 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

In fact this #2 is a JMS FAQ.

You need to start the receiver.
_________________
I am *not* the model of the modern major general.
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 » jndi problem
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.