This discussion is archived
0 Replies Latest reply: Jun 14, 2011 9:02 AM by 868827 RSS

error getting weblogic.jms.common.HdrMessageImpl@1cd0f92 instead of text

868827 Newbie
Currently Being Moderated
i am getting weblogic.jms.common.HdrMessageImpl@1cd0f92 instead of text when i send a TextMessage to JMS in weblogic 10.3. what could be the problem. here is the code for my JMS client application:


package home;

import java.util.Hashtable;
import javax.jms.*;
import javax.naming.*;

public class SimpleTest {
     
     static String connFactory = "TDS_CONN_FACTORY";
     static String destName = "TDS_INQUEUE";
     
     
     
     
     public static void main(String args[])
     {
          
          Hashtable env = new Hashtable();
          env.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
          env.put(Context.PROVIDER_URL,"t3://194.0.0.163:7007");

          
          String msg = "I am sending a message";
          
          /*
* Create a JNDI API InitialContext object if none exists
* yet.
*/
Context jndiContext = null;

try {
     //System.out.println("pass 1");
jndiContext = new InitialContext(env);
System.out.println("JNDI API context created successfully");
} catch (NamingException e) {
System.out.println("Could not create JNDI API context: " +
e.toString());
System.exit(1);
}

/*
* Look up connection factory and destination. If either
* does not exist, exit. If you look up a
* TopicConnectionFactory or a QueueConnectionFactory,
* program behavior is the same.
*/
ConnectionFactory connectionFactory = null;
Destination dest = null;

try {
     //System.out.println("pass 3");
connectionFactory = (ConnectionFactory) jndiContext.lookup(connFactory);
System.out.println("JNDI API lookup succeeded");
dest = (Destination) jndiContext.lookup(destName);
} catch (Exception e) {
System.out.println("JNDI API lookup failed: " + e.toString());
e.printStackTrace();
System.exit(1);
}




Connection connection = null;
MessageProducer producer = null;

try {

     connection = connectionFactory.createConnection();

Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
producer = session.createProducer(dest);

TextMessage message = session.createTextMessage();

     
message.setText(msg);
//message.setJMSType("xml");
System.out.println("Sending message: " + message.getText());
producer.send(message);



//* Send a non-text control message indicating end of
//* messages.

producer.send(session.createMessage());

System.out.println("Sent successfully");
} catch (JMSException e) {
System.out.println("Exception occurred: " + e.toString());
} finally {
if (connection != null) {
try {
connection.close();
} catch (JMSException e)
{

}

}
}

     }

}

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points