• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NullPointerExcepion while running jms sample example from jms tutorial

 
Jitendra Sonawane
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all ,
I am studying J2EE technology.
I have downloaded J2EESDK , j2ee , jms tutoral and jdk1.3 from java.sun.com.
I am working on JMS Api.
In jms tutorial , there are axamples like "SimpleQueueSender" and "SimpleTopicPublisher" in folder "simple".
Now I have done with all the requirements for j2ee server and jdk1.3.
j2ee server runs properly .
I compiled the source code and try to run the above files as per instructions given in tutorial.
"SimpleQueueSender/SimpleTopicPublisher" runs and throws "NullPointerException" with no stack trace available .
Exception occurs when QueueSender tries to send the message to Queue.
I am copying the exception and sample code here for "SimpleQueueSender" .

try {
queueConnection =
queueConnectionFactory.createQueueConnection();
queueSession =
queueConnection.createQueueSession(false,
Session.AUTO_ACKNOWLEDGE);
queueSender = queueSession.createSender(queue);


System.out.println("Sender 1: " + queueSender) ;
message = queueSession.createTextMessage();
for (int i = 0; i < NUM_MSGS; i++) {
message.setText("This is message " + (i + 1));
System.out.println("Sending message: " +
message.getText());
System.out.println("before sending ... ");
queueSender.send(message);
System.out.println("After sending ... ");
}
/////////////////
Error...
Queue name is MyQueue
Java(TM) Message Service 1.0.2 Reference Implementation (build b14)
Sending message: This is message 1
before sending ...
Exception occurred: java.lang.NullPointerException
java.lang.NullPointerException
<<no stack trace available>>

////////////////////
Can anyone Please tell me the reason why there will be NullPointerException ? It happens for both "SimpleQueueSender" and "SimpleTopicPublisher" .. while "SimpleQueueReceiver" and "SimpleTopicSubscriber" works properly .

Thx
Jitendra Sonawane
 
le taylom
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hiya,
I haven't tested this, but I think your message object is null. I think doing a getText on the message previous to sending it may null it.
???
T
 
Tero Ahonen
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a same kind of problem and the message object is not null. This exception is real mystery
[ February 01, 2002: Message edited by: Tero Ahonen ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic