Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > J2EE
|
J2EE General J2EE (Java 2 Enterprise Edition) discussions. Questions not specific to EE will be redirected elsewhere.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the J2EE section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 11th, 2005, 05:15 AM
Registered User
 
Join Date: Mar 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default javax.jms.InvalidDestinationException: MQJMS0003

Hi,

I'm becoming desperate because of this problem. If you have any idea please post it here.


I develop a web application which is intended to communicate with other apps via MQ. I work in Websphere Studio AD 5.0 and the application should run on Websphere Application Server 5.1. WAS should act only as a MQ client - the provider is Websphere MQ 5.3 CSD09 running on the same machine.


For working with MQ I have a class called MQAccessor, which has a sender (a QueueSender object), a receiver (a QueueReceiver) and a browser (a QueueBrowser). It initializes these objects in its constructor. For this it uses a QueueConnectionFactory object and Queue objects held on the server and accessible through JNDI.
The important part of the constructor code is bellow:


Code:
/* create session */
QueueConnectionFactory factory = (QueueConnectionFactory) context.lookup(queueConnectionFactoryJNDIName);
connection = factory.createQueueConnection();
session = connection.createQueueSession(true, Session.AUTO_ACKNOWLEDGE);

/* find queues in JNDI */
Queue inQueue = null;
Queue outQueue = null;
if(inQueueJNDIName != null){
    inQueue = (Queue) context.lookup(inQueueJNDIName);
}
if(outQueueJNDIName != null){
    outQueue = (Queue) context.lookup(outQueueJNDIName);
    ((MQQueue)outQueue).setTargetClient(JMSC.MQJMS_CLIENT_NONJMS_MQ);
}

/* create sender/receiver/browser */
if(inQueue != null){
    receiver = session.createReceiver(inQueue);
    browser = session.createBrowser(inQueue);
}
if(outQueue != null){
    sender = session.createSender(outQueue);
}

/* start connection */
connection.start();

OK, now the problem: when I deploy the application on the server (WAS 5.1 as written above) the method session.createRecever() (or session.createSender(), when inQueue is null) throws the exception javax.jms.InvalidDestinationException: MQJMS0003: Destination not understood or no longer valid. There are two wierd things about it:

1, When I lookup the same Queue object with another application which uses nearly the same class for working with MQ everything is OK. Therefore I think the Queue should be valid.

2, When I run the application on the test server integrated in WSAD with the same objects defined everything works fine!


Especially the second thing is really wierd - if it runs properly on the test server in WSAD why the hell it fails on the WAS?


The exception stacktrace follows:

Code:
[10.3.05 14:49:19:180 SEÈ] 1c3ea0ea SystemErr     R javax.jms.InvalidDestinationException: MQJMS0003: Destination not understood or no longer valid
[10.3.05 14:49:19:180 SEÈ] 1c3ea0ea SystemErr     R     at com.ibm.mq.jms.MQSession.createQReceiver(MQSession.java:5722)
[10.3.05 14:49:19:180 SEÈ] 1c3ea0ea SystemErr     R     at com.ibm.mq.jms.MQQueueSession.createReceiver(MQQueueSession.java:293)
[10.3.05 14:49:19:180 SEÈ] 1c3ea0ea SystemErr     R     at com.ibm.mq.jms.MQQueueSession.createReceiver(MQQueueSession.java:272)
[10.3.05 14:49:19:180 SEÈ] 1c3ea0ea SystemErr     R     at com.ibm.ejs.jms.JMSQueueReceiverHandle.<init>(JMSQueueReceiverHandle.java:84)
[10.3.05 14:49:19:180 SEÈ] 1c3ea0ea SystemErr     R     at com.ibm.ejs.jms.JMSQueueSessionHandle.createReceiver(JMSQueueSessionHandle.java:144)
[10.3.05 14:49:19:180 SEÈ] 1c3ea0ea SystemErr     R     at cz.empire.mq4db.componentpart.MQAccessor.<init>(MQAccessor.java:72)
[10.3.05 14:49:19:180 SEÈ] 1c3ea0ea SystemErr     R     at cz.empire.mq4db.ComponentBase.initComponent(ComponentBase.java:283)
[10.3.05 14:49:19:180 SEÈ] 1c3ea0ea SystemErr     R     at cz.empire.mq4db.ComponentSynchronized.mainLoop(ComponentSynchronized.java:32)
[10.3.05 14:49:19:180 SEÈ] 1c3ea0ea SystemErr     R     at cz.empire.mq4db.ComponentThread.run(ComponentThread.java:35)
It's my third day I try to solve the problem and it's really frustrating so as I said, if you have any idea please post it. Thanks a lot.
 
Old June 17th, 2008, 05:31 PM
Registered User
 
Join Date: Jun 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The problem is the IBM class com.ibm.mq.jms.MQSession.createQSender has the following code

************************************************** **************************************** ************************************************** **********
if(!(queue instanceof com.ibm.mq.jms.MQQueue))
{
String s1 = "MQJMS0003";
String s3 = ConfigEnvironment.getErrorMessage(s1);
s3 = s3 + buildExceptionString(queue);
InvalidDestinationException invaliddestinationexception = new InvalidDestinationException(s3, s1);
throw invaliddestinationexception;
}
mqqueue = (com.ibm.mq.jms.MQQueue)queue;
mqqueue1 = getServicesMgr().getOutputQueue(mqqueue, this);
}
************************************************** **************************************** ************************************************** **********
At first all looks straight forward but there is a bigger problem.

instanceOf operator of java would return false for objects of the same class if they are being loaded by different classloaders.

In my case i had many webapplications and the Queue object was got by a jndi lookup. Now when first time this code is executed it all works fine for a application but when you start using anohter web application the same code fails and throws the InvalidDestinationException .

The reason being the 2 objects on which ibm code is doing instanceof are loaded by different classloaders.

The Solution to this problem is delete all the ibm jars (com.ibm.mq.jar and com.ibm.mqjms.jar) from individual web application and add these in the servers lib directory. Now all instances are loaded by the server classloader and not by webappclassloaders .

If MQQueue had a serialversionuid then this problem wouldnt have occured.

This is a criptic issue which took me 2 days to figure out.


 
Old June 20th, 2008, 01:24 PM
Authorized User
 
Join Date: Apr 2005
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Or may be you can use SingleClassloader for all the webapplications
 
Old June 20th, 2008, 01:31 PM
Authorized User
 
Join Date: Apr 2005
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Do you share "inQueue" object between the web applications? In case you do not, then it might be likely that the InitialContext has cached the lookup object ffor "inQueue" which could cause the InvalidDestinationException





Similar Threads
Thread Thread Starter Forum Replies Last Post
jms implementation yanis97 J2EE 0 August 31st, 2006 04:29 AM
jms or web service yanis97 J2EE 0 August 25th, 2006 10:03 AM
Please Help Me IN JMS shailsneh J2EE 0 March 23rd, 2005 09:40 AM
Chapter 6 of Proffesional JMS aravind_prasanna All Other Wrox Books 0 March 5th, 2005 02:43 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.