|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
ArrayIndexOutOfBoundsException in a com.ibm.mq class |
« View previous topic :: View next topic » |
Author |
Message
|
fcasali |
Posted: Wed Dec 01, 2004 5:55 am Post subject: ArrayIndexOutOfBoundsException in a com.ibm.mq class |
|
|
Novice
Joined: 09 Jul 2004 Posts: 12 Location: Torino, Italy
|
I'm a beginner with JMS programming and I'm writing a simple application that writes a message in a queue with a certain correlation ID, do something and then browse the response from another queue using the same correlation ID as selector.
With my great surprise I receive the following exception arising from a call to the MQQueueEnumeration.hasMoreElements() method:
java.lang.ArrayIndexOutOfBoundsException
at com.ibm.mq.MQDateConverter.fastDateToMillis(MQDateConverter.java:250)
at com.ibm.mq.MQDateConverter.mqDateTimeToMillis(MQDateConverter.java:318)
at com.ibm.mq.MQMsg2.getPutTimeMillis(MQMsg2.java:1067)
at com.ibm.mq.jms.MQJMSMessage.setHeaderFromMQMD_on_Receive(MQJMSMessage.java:858)
at com.ibm.mq.jms.MQJMSMessage.createJMSMessage(MQJMSMessage.java:522)
at com.ibm.mq.jms.MQQueueEnumeration.retrieveMessage(MQQueueEnumeration.java:277)
at com.ibm.mq.jms.MQQueueEnumeration.hasMoreElements(MQQueueEnumeration.java:146)
at rma.sigea.sm.resource.manager.MQJmsManagerImpl.browse(MQJmsManagerImpl.java:153)
at rma.sigea.component.runner.RunnerMQSync.execute(RunnerMQSync.java:204)
at rma.sigea.sm.lib.connector.ConnectorServlet.doPost(ConnectorServlet.java:369)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
...
Somebody as any suggestion ? _________________ Regards,
Fabrizio Casali
IT Specialist Advisory |
|
Back to top |
|
 |
bower5932 |
Posted: Wed Dec 01, 2004 6:22 am Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
What version of WMQ are you using (use mqver)? Also, can you post the code fragment that is actually getting the error? |
|
Back to top |
|
 |
fcasali |
Posted: Wed Dec 01, 2004 7:11 am Post subject: |
|
|
Novice
Joined: 09 Jul 2004 Posts: 12 Location: Torino, Italy
|
Thank you for the reply. The following is the fragment of code that produce the exception even if it's difficult to extract all the needed code:
the MQ logic is simple but is nested in a more structured application.
However I'm using the MQ v5.3.1 on OS/390.
This is the code (please note that MQTransaction and JmsInteraction are simple custom classes for grouping all the correlated info and objects for the transaction):
public String browse(MQTransaction transaction) throws CoreException
{
// Instantiates connection, session and destination
JmsInteraction interaction = startJmsInteraction(transaction, "MQManagerImpl.browse");
// Allocates a browser
QueueBrowser browser = JmsUtils.getBrowser(interaction.session, interaction.queue, getSelector(transaction.correlation));
try {
Enumeration enum = browser.getEnumeration();
if (enum.hasMoreElements()) <---- THIS PRODUCES THE EXCEPTION
{
// Browse next message (one expected at the moment ...)
TextMessage message = (TextMessage) enum.nextElement();
if (enum.hasMoreElements())
throw new CoreException("More than one message with correlation ID "+transaction.correlation);
return message.getText();
}
throw new CoreException("No message found");
} catch (Throwable e) {
interaction.trace.error(e);
throw new CoreException("Cannot browse message "+transaction.correlation+" from Queue "+transaction.connection.serverName+"/"+transaction.queue),
RC_SERVLET_MQ_READ_ERROR);
} finally {
// release resources (sender, session e connection)
stopJmsInteraction(interaction, "MQManagerImpl.browse");
}
} _________________ Regards,
Fabrizio Casali
IT Specialist Advisory |
|
Back to top |
|
 |
csmith28 |
Posted: Wed Dec 01, 2004 7:52 am Post subject: |
|
|
 Grand Master
Joined: 15 Jul 2003 Posts: 1196 Location: Arizona
|
Good thing you didn't get the OffSides or PassInterferanceException.
Code: |
sarcd ended reason code 0 |
_________________ Yes, I am an agent of Satan but my duties are largely ceremonial. |
|
Back to top |
|
 |
bower5932 |
Posted: Wed Dec 01, 2004 11:39 am Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
The following worked for me:
Code: |
public void myBrowser() {
Queue queue = null;
QueueBrowser qBrowser = null;
QueueSession session = null;
QueueConnection connection = null;
QueueConnectionFactory factory = null;
Message message = null;
int j = 0;
System.out.println("\namqsbcgjms.java - starts here");
System.out.println("**************************");
/**********************************/
/* Get the context factory. */
/**********************************/
Hashtable environment = new Hashtable();
environment.put(Context.INITIAL_CONTEXT_FACTORY, icf);
environment.put(Context.PROVIDER_URL, url);
environment.put(Context.REFERRAL, "throw");
try {
ctx = new InitialDirContext( environment );
} catch( Exception e ) {
System.err.println("Error during lookup of Context Factory " + e);
System.err.println(e);
return;
}
/****************************************/
/* Lookup the queue connection factory. */
/****************************************/
try {
factory = (QueueConnectionFactory)ctx.lookup(lookupQCF);
} catch( Exception e ) {
System.out.println("QCF Lookup error: " + e);
System.err.println(e);
return;
}
/****************************************/
/* Lookup the queue. */
/****************************************/
try {
queue = (Queue)ctx.lookup(lookupQ);
} catch( Exception e ) {
System.out.println( "Error during lookup of Queue" + e.getMessage());
System.err.println(e);
return;
}
try {
System.out.println(" Create objects.");
System.out.println("");
connection = factory.createQueueConnection();
connection.start();
boolean transacted = false;
session = connection.createQueueSession( transacted,
Session.AUTO_ACKNOWLEDGE);
qBrowser = session.createBrowser(queue);
Enumeration messageEnum = qBrowser.getEnumeration();
while (messageEnum.hasMoreElements()) {
message = (Message)messageEnum.nextElement();
j = j + 1;
System.out.println(" GET of message number " + j);
System.out.println(" Message: " + message);
System.out.println();
System.out.println();
}
System.out.println(" No more messages");
/*********************************************/
/* Make sure that all objects are closed and */
/* that the handles are set to null. */
/*********************************************/
System.out.println(" Cleaning up");
qBrowser.close();
System.out.println(" CLOSE of queue");
session.close();
session = null;
connection.close();
connection = null;
System.out.println(" DISCONNECT from queue manager");
} catch( JMSException je ) {
/*******************************************/
/* Catch and display exception information */
/*******************************************/
System.out.println("JMSException: " + je);
Exception le = je.getLinkedException();
if (le != null) System.out.println("Linked exception: " + le);
} catch( Exception e ) {
/*******************************************/
/* Catch and display exception information */
/*******************************************/
System.out.println("Exception: " + e);
}
System.out.println("browsing finished...");
} |
|
|
Back to top |
|
 |
fcasali |
Posted: Thu Dec 02, 2004 1:28 am Post subject: |
|
|
Novice
Joined: 09 Jul 2004 Posts: 12 Location: Torino, Italy
|
OK, I have seen your code: there is no meaningful difference respect to mine.
Only one thing:
Code: |
Hashtable environment = new Hashtable();
environment.put(Context.INITIAL_CONTEXT_FACTORY, icf);
environment.put(Context.PROVIDER_URL, url);
environment.put(Context.REFERRAL, "throw");
|
The property REFERRAL is required only if you register MQ objects on LDAP or is mandatory with iiop protocol too? _________________ Regards,
Fabrizio Casali
IT Specialist Advisory |
|
Back to top |
|
 |
slaupster |
Posted: Mon Dec 06, 2004 4:49 am Post subject: |
|
|
Apprentice
Joined: 17 Nov 2004 Posts: 41
|
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|