• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

NullPointerExcepion while running jms sample example from jms tutorial

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
I RELEASE YOU! (for now .... ) Feel free to peruse this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic