It is a race condition between initialized process by Jboss messaging and process by Web application.
This program is getting executed during service startup. It is working fine now after thread sleep of 1sec.
Before Change
TopicConnectionFactory _factory = (TopicConnectionFactory)context.lookup("java:JmsXA");
TopicConnection _connection = _factory.createTopicConnection();
TopicSession _session = _connection.createTopicSession(false, 1); //This is the place where it hanged.
Topic _topic = (Topic)context.lookup(s);
TopicPublisher _publisher = _session.createPublisher(_topic);
_connection.start();
After Change
TopicConnectionFactory _factory = (TopicConnectionFactory)context.lookup("java:JmsXA");
TopicConnection _connection = _factory.createTopicConnection();
Thread.sleep(1000); //After introducing this line, it is working fine.
TopicSession _session = _connection.createTopicSession(false, 1);
Topic _topic = (Topic)context.lookup(s);
TopicPublisher _publisher = _session.createPublisher(_topic);
_connection.start();