Skip to Content
avatar image
Former Member

JMSException

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");

tMessage.setStringProperty("Client","Madan");

tPublisher.publish(tMessage);

out.println("Message sent .");

TopicSubscriber ts=tSession.createSubscriber(topic);

topicConnection.start();

Message m =ts.receive();

out.println(m instanceof TextMessage);

out.println("hello");

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());

tSession.close();

topicConnection.close();

%>

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    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

    Peter

    Add comment
    10|10000 characters needed characters exceeded