Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

java.lang.ClassCastException: javax.naming.Reference incompatible with javax.jms.Que  RSS feed

 
suresh sai
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All.,
I am trying to execute a simple MESSAGE DRIVEN BEAN from a simple java application in RAD 7.0 tool with Application Server 6.0. But, While executing the application I am getting the following exception.

WARNING: jndiGetObjInstNoop
java.lang.ClassCastException: javax.naming.Reference incompatible with javax.jms.QueueConnectionFactory
 
aleem khan
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the code?
 
Scott Wade
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you ever get this to work? I'm having the same problem. Here is my code.

String messageString = "hello world";


System.out.println("Getting Initial Context");
Properties props = new Properties();

props.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");

props.put(Context.PROVIDER_URL,"iiop://localhost:10004/");

InitialContext context = new InitialContext(props);
System.out.println("Getting Connection Factory");

String lookupString =
"cell/nodes/h6m4r/servers/server1/jms/MyConnectionFactory";
ConnectionFactory cf = (ConnectionFactory)context.lookup(lookupString);


System.out.println("Getting Queue");
Destination dest = (Destination)context.lookup("cell/nodes/h6m4r/servers/server1/jms/MyDestinationRef");
System.out.println("Creating connection");
Connection conn = cf.createConnection();
System.out.println("Creating Session");
Session jmsSession = conn.createSession(false,Session.AUTO_ACKNOWLEDGE);
System.out.println("Creating Sender");
MessageProducer producer = jmsSession.createProducer(dest);
System.out.println("Creating Text");
TextMessage message = jmsSession.createTextMessage();
System.out.println("Appending command Line");
System.out.println("Setting Text");
message.setText(messageString);
System.out.println("Sending message");
producer.send(message);
System.out.println("Closing sender");
producer.close();
System.out.println("Closing session");
jmsSession.close();
System.out.println("Closing connection");
conn.close();
System.out.println("Connection closed");
 
Venkateswara Rao Desu
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I too have the same problem, it looks like it is giving "javax.naming.Reference" class instead of ConnectionFactory ,...

I would like to know is there a way to convert that into ConnectionFactory ,
Please correct me if I am wrong
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!