Skip to Content
author's profile photo Former Member
Former Member


Hi i am creating jms-factory nd jmsdestination from

"ear" application

and in the same application i have one jsp it will publish the messages to the topic as well as fetched from that topic.

Now problem is it is creating factory and destination and it is publishing messages also i am able to see in databse

but it is not fetching values from that topic,it is throwing NullpointerException

This is the jsp i have


ctx=new InitialContext();

topicFactory =(TopicConnectionFactory)ctx.lookup("jmsfactory/default/TopicConnectionFactory");

topicConnection = topicFactory.createTopicConnection();

tSession =topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);

topic = (Topic) ctx.lookup("jmstopics/default/OTCDestinationTopic");

TopicPublisher tPublisher = tSession.createPublisher(topic);

TextMessage tMessage = tSession.createTextMessage();

tMessage.setText("publishing the messages to the Topic");



out.println("Message sent .");

TopicSubscriber ts=tSession.createSubscriber(topic);


Message m =ts.receive();

out.println(m instanceof TextMessage);


TextMessage txt = (TextMessage) m;

out.println("MessageReceived: "+txt.getText());

out.println("MessageReceived: "+txt.getStringProperty("Client"));

out.println("MessageReceived: "+txt.getJMSDestination());

out.println("Message Received: "+txt.getJMSMessageID());

out.println("Message Received: "+txt.getJMSTimestamp());




Add comment
10|10000 characters needed characters exceeded

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Oct 18, 2006 at 06:05 AM

    Hi Madan,

    If you post your NullPointerException or perhaps tell exactly which line of your program has lead to it, maybe me or someone else with bigger JMS knowledge could be able to help you

    Best Regards


    Add comment
    10|10000 characters needed characters exceeded