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 » QueueManager object failing when running code

Post new topic  Reply to topic Goto page 1, 2  Next
 QueueManager object failing when running code « View previous topic :: View next topic » 
Author Message
joojoogame
PostPosted: Mon Dec 05, 2005 3:27 am    Post subject: QueueManager object failing when running code Reply with quote

Newbie

Joined: 05 Dec 2005
Posts: 9

i want to create a simplechat application with JMS publish/subscribe mode using IBM Websphere MQ. the queuemanager QM_APPLE is on the same machine. the code compiles but i get the exception:

javax.jms.JMSException: MQJMS2005: failed to create MQQueueManager for 'localhos
t:QM_APPLE'
at com.ibm.mq.jms.services.ConfigEnvironment.newException(ConfigEnvironm
ent.java:586)
at com.ibm.mq.jms.MQConnection.createQM(MQConnection.java:2110)
at com.ibm.mq.jms.MQConnection.createQMNonXA(MQConnection.java:1532)
at com.ibm.mq.jms.MQTopicConnection.<init>(MQTopicConnection.java:224)
at com.ibm.mq.jms.MQTopicConnectionFactory.createMQTopicConnection(MQTop
icConnectionFactory.java:371)
at com.ibm.mq.jms.MQTopicConnectionFactory.createTopicConnection(MQTopic
ConnectionFactory.java:270)
at Chat.<init>(Chat.java:41)
at p.main(p.java:101)





I believe there is some connection problem but i cannot pinpoint it.






here is the topic:

InitCtx> display t(newtopic)

BROKERPUBQMGR()
FAILIFQUIESCE(YES)
BROKERDURSUBQ(SYSTEM.JMS.D.SUBSCRIBER.QUEUE)
BROKERPUBQ()
BROKERVER(V1)
PERSISTENCE(APP)
CCSID(1208)
TARGCLIENT(JMS)
ENCODING(NATIVE)
BROKERCCDURSUBQ(SYSTEM.JMS.D.CC.SUBSCRIBER.QUEUE)
MULTICAST(ASCF)
PRIORITY(APP)
EXPIRY(APP)
VERSION(6)

here is the topic connection factory:

InitCtx> display tcf(TopicConnectionFactory)

CCSID(819)
BROKERSUBQ(SYSTEM.JMS.ND.SUBSCRIBER.QUEUE)
PORT(1414)
SYNCPOINTALLGETS(NO)
PUBACKINT(25)
POLLINGINT(5000)
RECEIVEISOLATION(COMMITTED)
MSGSELECTION(CLIENT)
OUTCOMENOTIFICATION(YES)
CHANNEL(SYSTEM.DEF.SVRCONN)
OPTIMISTICPUBLICATION(NO)
BROKERCONQ(SYSTEM.BROKER.CONTROL.QUEUE)
USECONNPOOLING(YES)
HOSTNAME(localhost)
CLONESUPP(DISABLED)
LOCALADDRESS()
SPARSESUBS(NO)
VERSION(6)
BROKERCCSUBQ(SYSTEM.JMS.ND.CC.SUBSCRIBER.QUEUE)
PROCESSDURATION(UNKNOWN)
SSLRESETCOUNT(0)
CONNOPT(STANDARD)
BROKERQMGR()
SSLFIPSREQUIRED(NO)
FAILIFQUIESCE(YES)
CLEANUP(SAFE)
RESCANINT(5000)
MSGBATCHSZ(10)
BROKERPUBQ(SYSTEM.BROKER.DEFAULT.STREAM)
QMANAGER(QM_APPLE)
BROKERVER(V1)
CLEANUPINT(3600000)
STATREFRESHINT(60000)
SUBSTORE(MIGRATE)
TRANSPORT(CLIENT)
TARGCLIENTMATCHING(YES)



What do you think is the problem ? could you suggest things i could try to get this connection working ? this is my environment setting.


MQEnvironment.hostname = "127.0.0.1";
MQEnvironment.channel = "JAVA.CHANNEL";
Properties env = new Properties( );
String CTX_FACTORY = "com.sun.jndi.fscontext.RefFSContextFactory";
String INIT_URL = "file:/C:/lib";
env.put( Context.INITIAL_CONTEXT_FACTORY, CTX_FACTORY );
env.put( Context.PROVIDER_URL, INIT_URL );
env.put( Context.REFERRAL, "throw" );


anu suggestions would be much appreciated. thank you
Back to top
View user's profile Send private message
wschutz
PostPosted: Mon Dec 05, 2005 3:45 am    Post subject: Reply with quote

Jedi Knight

Joined: 02 Jun 2005
Posts: 3316
Location: IBM (retired)

Do you know if you have a listener running at port 1414? You mention that your java pgm is running on the same machine, but your TCF specifies a client connection. (and thats okay, provided thats what you intended to do). You can specify a server connection.

If you really meant a client connection, then ensure that you have a MQ listener running on port 1414 for that qmgr, here's a quick way to do that:

set MQSERVER=SYSTEM.DEF.SVRCONN/tcp/localhost(1414)
amqsputc SYSTEM.DEFAULT.LOCAL.QUEUE QM_APPLE


If you can put a message to that queue, then you have a listener running....
_________________
-wayne
Back to top
View user's profile Send private message Send e-mail AIM Address
joojoogame
PostPosted: Mon Dec 05, 2005 5:25 am    Post subject: thank you Reply with quote

Newbie

Joined: 05 Dec 2005
Posts: 9

like you suggested i forgot to set up a listener for this queue manager. i am running the server on windows2000 and the msdos commands dont work most of the time for mq. so i had to make the queue default through gui. i traced a return code for the msdos command you suggested to bad environment settings. please tell me how to configure libraries in mq. the previous exception has disappeared but i still have a snag.

javax.jms.JMSSecurityException: MQJMS2013: invalid security authentication suppl
ied for MQQueueManager

i dont know how to set authentication info. i tried to use the explorer but the auth info i entered there asks me for a ldap server. i am not running one. is there a config file through which i can allow anon connections ? or could you suggest a way to set the user name and pass word. currently i am trying to coonect with username:user password:pass. calls to createTopicConnection() constructor ( ie without user or pass )still throw me the same error. thank you
Back to top
View user's profile Send private message
joojoogame
PostPosted: Mon Dec 05, 2005 7:59 am    Post subject: Reply with quote

Newbie

Joined: 05 Dec 2005
Posts: 9

i tried to execute setmqaut but i get this error:

C:\MQ\MSI\BIN>setmqaut -m QM_APPLE -n a* -t q -p user +all
WebSphere MQ was unable to display an error message 893.
AMQ0893

it says there is a duplicate dll file but even after i removed it , the same error is displayed. is there some way i can set authority by using gui without ldap server ?
Back to top
View user's profile Send private message
wschutz
PostPosted: Mon Dec 05, 2005 9:52 am    Post subject: Reply with quote

Jedi Knight

Joined: 02 Jun 2005
Posts: 3316
Location: IBM (retired)

I think you need to straighten up your MQ install first so that you can run setmqaut. Is this a new install? Did you install it yourself? What duplicate dll are you referring to?

There is no GUI equivalent in the product for setmqaut.
_________________
-wayne
Back to top
View user's profile Send private message Send e-mail AIM Address
joojoogame
PostPosted: Mon Dec 05, 2005 11:34 am    Post subject: Reply with quote

Newbie

Joined: 05 Dec 2005
Posts: 9

i have corrected the duplicate dll problem. i had the dll for backup reasons in the wrong directory. i have now set up a domain user named user. i successfully set the authority and started a broker for my queue QM_APPLE and verified that it was running. the program now partially works. here are my two errors:

if i include a subscriber in my code like this:



TopicSubscriber subscriber =
subSession.createSubscriber(chatTopic);


i get this:



javax.jms.JMSException: MQJMS1016: an internal error has occurred. Please contac
t your system administrator. Detail: {0}
at com.ibm.mq.jms.services.ConfigEnvironment.newException(ConfigEnvironm
ent.java:567)
at com.ibm.mq.jms.MQMigrateSubscriptionEngine.openSubscription(MQMigrate
SubscriptionEngine.java:246)
at com.ibm.mq.jms.MQSession.createTSubscriber(MQSession.java:5083)
at com.ibm.mq.jms.MQTopicSession.createSubscriber(MQTopicSession.java:54
1)
at p.<init>(p.java:62)
at p.main(p.java:110)



so i commented the subscriber to check if the publisher works. it works only once. here is the output:

hello
hi
javax.jms.JMSException: MQJMS3010: Failed to build publish message
at com.ibm.mq.jms.services.ConfigEnvironment.newException(ConfigEnvironm
ent.java:567)
at com.ibm.mq.jms.MQMessageProducer.buildBaseMessage(MQMessageProducer.j
ava:2795)
at com.ibm.mq.jms.MQMessageProducer.publishInt(MQMessageProducer.java:19
39)
at com.ibm.mq.jms.MQMessageProducer.publishInt(MQMessageProducer.java:21
13)
at com.ibm.mq.jms.MQTopicPublisher.publish(MQTopicPublisher.java:237)
at p.writeMessage(p.java:95)
at p.main(p.java:122)



why does it fail the second time i try to publish a message ? am i supposed to flush some buffer ? here is the line that fails.

message.setText(username+" : "+text);


Your inputs so far have been very helpful. could you please tell me what could be wrong. i will try to solve it by looking around meanwhile. thank you
Back to top
View user's profile Send private message
wschutz
PostPosted: Mon Dec 05, 2005 11:51 am    Post subject: Reply with quote

Jedi Knight

Joined: 02 Jun 2005
Posts: 3316
Location: IBM (retired)

Maybe you should post your code here so we can see it...
_________________
-wayne
Back to top
View user's profile Send private message Send e-mail AIM Address
bower5932
PostPosted: Mon Dec 05, 2005 12:15 pm    Post subject: Reply with quote

Jedi Knight

Joined: 27 Aug 2001
Posts: 3023
Location: Dallas, TX, USA

You could also go look at mqjmssub.java and mqjmspub.java at:

http://www.developer.ibm.com/isv/tech/sampmq.html
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
joojoogame
PostPosted: Mon Dec 05, 2005 7:49 pm    Post subject: Reply with quote

Newbie

Joined: 05 Dec 2005
Posts: 9

here is my code :



import com.ibm.mq.jms.*;
import com.ibm.mq.*;
import javax.jms.*;
import javax.naming.*;
import java.io.*;
import java.io.InputStreamReader;
import java.util.Properties;



public class p implements javax.jms.MessageListener
{
private TopicSession pubSession;
private TopicSession subSession;
private TopicPublisher publisher;
private TopicConnection connection;
private String username;

public p(String topicName, String username, String password)
throws Exception {

Properties env = new Properties( );

String CTX_FACTORY = "com.sun.jndi.fscontext.RefFSContextFactory";
String INIT_URL = "file:/C:/lib";

env.put( Context.INITIAL_CONTEXT_FACTORY, CTX_FACTORY );
env.put( Context.PROVIDER_URL, INIT_URL );
env.put( Context.REFERRAL, "throw" );
InitialContext jndi = new InitialContext(env);

TopicConnectionFactory conFactory =
(TopicConnectionFactory)jndi.lookup("TopicConnectionFactory");




TopicConnection connection =
//conFactory.createTopicConnection(username,password);
conFactory.createTopicConnection();


TopicSession pubSession =
connection.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
TopicSession subSession =
connection.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);

Topic chatTopic = (Topic)jndi.lookup(topicName);


TopicPublisher publisher =
pubSession.createPublisher(chatTopic);
TopicSubscriber subscriber =
subSession.createSubscriber(chatTopic);


subscriber.setMessageListener(this);


set(connection, pubSession, subSession, publisher, "user");
connection.start( );

}



public void set(TopicConnection con, TopicSession pubSess,
TopicSession subSess, TopicPublisher pub,
String username)
{
this.connection = con;
this.pubSession = pubSess;
this.subSession = subSess;
this.publisher = pub;
this.username = username;
}
public void onMessage(Message message) {
try {
TextMessage textMessage = (TextMessage) message;
String text = textMessage.getText( );
System.out.println(text);
} catch (JMSException jmse){ jmse.printStackTrace( ); }
}
protected void writeMessage(String text) throws JMSException {
TextMessage message = pubSession.createTextMessage( );
System.out.println(text);
message.setText(username+" : "+text);
publisher.publish(message);
}
public void close( ) throws JMSException {
connection.close( );
}





public static void main(String[] args)
{
System.out.println("Starting...");
try{

p chat = new p("newtopic","user","test");
BufferedReader commandLine = new
java.io.BufferedReader(new InputStreamReader(System.in));

while(true)
{
String s = commandLine.readLine( );
if (s.equalsIgnoreCase("exit"))
{
chat.close( );
System.exit(0);
} else
chat.writeMessage(s);
}
}
catch (Exception e){ e.printStackTrace( );
{
}
}
}
}









i tried out the example in the ibm site but it compiled with a warning and failed to recognise the context factory.


when i compile and run my code i get this:



C:\JAVA>java p
Starting...
javax.jms.JMSException: MQJMS1016: an internal error has occurred. Please contac
t your system administrator. Detail: {0}
at com.ibm.mq.jms.services.ConfigEnvironment.newException(ConfigEnvironm
ent.java:567)
at com.ibm.mq.jms.MQMigrateSubscriptionEngine.openSubscription(MQMigrate
SubscriptionEngine.java:246)
at com.ibm.mq.jms.MQSession.createTSubscriber(MQSession.java:5083)
at com.ibm.mq.jms.MQTopicSession.createSubscriber(MQTopicSession.java:54
1)
at p.<init>(p.java:55)
at p.main(p.java:105)






also when i comment the 55th line a new problem arises everytime i publish the second time. it either hangs up and doesnt let me input anything or it says cannot publish. please help
Back to top
View user's profile Send private message
joojoogame
PostPosted: Tue Dec 06, 2005 12:23 am    Post subject: Reply with quote

Newbie

Joined: 05 Dec 2005
Posts: 9

The IBM example for publish worked after i rebooted my system and restarted my broker. however i still get an error for the subscribe example mqjmssub. the exception is thrown at the same line where my code failed.

tSub creation exception: javax.jms.JMSException: MQJMS1016: an internal error ha
s occurred. Please contact your system administrator. Detail: {0}
Linked exception: java.lang.NullPointerException

line : tSub = session.createSubscriber(topic);


please suggest a fix. i m sure it issome config problem. thank you
Back to top
View user's profile Send private message
joojoogame
PostPosted: Tue Dec 06, 2005 1:07 am    Post subject: Reply with quote

Newbie

Joined: 05 Dec 2005
Posts: 9

Here is the stack trac, if it helps.



tSub creation exception: javax.jms.JMSException: MQJMS1016: an internal error ha
s occurred. Please contact your system administrator. Detail: {0}
Linked exception: java.lang.NullPointerException
java.lang.NullPointerException
at java.util.Hashtable.put(Hashtable.java:396)
at com.ibm.mq.jms.MQBrokerMessage.set(MQBrokerMessage.java:360)
at com.ibm.mq.jms.MQBrokerSubscriptionEngine.sendBrokerMessageInternal(M
QBrokerSubscriptionEngine.java:2692)
at com.ibm.mq.jms.MQBrokerSubscriptionEngine.setDeferredMessage(MQBroker
SubscriptionEngine.java:2868)
at com.ibm.mq.jms.MQBrokerSubscriptionEngine.openSubscription(MQBrokerSu
bscriptionEngine.java:234)
at com.ibm.mq.jms.MQMigrateSubscriptionEngine.openSubscription(MQMigrate
SubscriptionEngine.java:200)
at com.ibm.mq.jms.MQSession.createTSubscriber(MQSession.java:5083)
at com.ibm.mq.jms.MQTopicSession.createSubscriber(MQTopicSession.java:54
1)
at mqjmssub.mySubscriber(mqjmssub.java:272)
at mqjmssub.main(mqjmssub.java:398)
Back to top
View user's profile Send private message
wschutz
PostPosted: Tue Dec 06, 2005 3:42 am    Post subject: Reply with quote

Jedi Knight

Joined: 02 Jun 2005
Posts: 3316
Location: IBM (retired)

Are you getting this latest error off the samples or your code? A NullPointerException almost always means your trying to use an object (in this case I'd guess "session") but it hasn't been instantiated.
_________________
-wayne
Back to top
View user's profile Send private message Send e-mail AIM Address
joojoogame
PostPosted: Tue Dec 06, 2005 4:58 am    Post subject: Reply with quote

Newbie

Joined: 05 Dec 2005
Posts: 9

I got the program to work. i used the IBM sample programsand modified them here n there but it works only because the topic is generated dynamically. here is the problem:

i created a topic named newtopic. the publisher works like a charm both for my code and the IBM sample code. the problem is for the subscriber. when i run the IBM sample code like this:

C:\JAVA>java mqjmssub -icf com.sun.jndi.fscontext.RefFSContextFactory -url file: /C:/lib -tcf TopicConnectionFactory -t newtopic

it creates a null pointer exception and i think it can be traced to the topic object which is initialized as

topic = (Topic)ctx.lookup(lookupTopic);

the lookupTopic variable is fine and holds the valur newtopic but the object returned is "topic://" while it should be "topic://newtopic".

when i specify a topic name that does not exist. the IBM sample program generates a topic dynamically and the pub/sub model works.

This is the command line that dynamically creates the topic.
C:\JAVA>java mqjmssub -icf com.sun.jndi.fscontext.RefFSContextFactory -url file:/C:/lib -tcf TopicConnectionFactory -t sometopic

this is the topic object printed on the screen:
topic is: topic://sometopic

Topic Subscriber object which is the same even if i mention newtopic as the topic :
tSub is com.ibm.mq.jms.MQTopicSubscriber@1034bb5

Success when creating topic dynamically:
created subscriber.
Hit enter to end...

the publisher is able to send messages to the subscriber and i have tested the same.

Why do you think this happens ? is the topic object to blame ?

Another thing that i am a touch confused about is:

this dynamically created topic does not associate itself with a queue manager and a queue right ? can i dynamically set properties in the code ? if i want to refuse a subscriber from subscribing to a topic it should be possible by associating the brokerpubqmgr and brokerpubq with QM_APPLE and a queue in that manager. am i right about that ?

thank you for helping me out
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Dec 06, 2005 9:15 pm    Post subject: Reply with quote

Grand High Poobah

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

When you create the topic for your file jndi ref you should possibly only use an existing topic on the qmgr??

If the topic has never been created you would not be able to resolve the topic when you retrieve it from JNDI thus getting a null ref.

Enjoy
Back to top
View user's profile Send private message Send e-mail
joojoogame
PostPosted: Wed Dec 07, 2005 4:24 am    Post subject: Reply with quote

Newbie

Joined: 05 Dec 2005
Posts: 9

the topic newtopic has already been defined but it seems to me that it is the lookup that is failing each time. i dont know why. however dynamic topics are created with ease.
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 » QueueManager object failing when running code
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.