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

JMS Client not working in JSP  RSS feed

Premkumar Mudaliar
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following code is a simple JMS Sender that works fine when executed in command prompt locally
i.e in the system where the server is installed. However the same code doesnt work when executed from
inside a jsp in the server itself.
Context jndiContext = null;
QueueConnectionFactory queueConnectionFactory = null;
QueueConnection queueConnection = null;
QueueSession queueSession = null;
Queue queue = null;
QueueSender queueSender = null;
ObjectMessagemessage = null;
String queueName = "jms/PaymentsQueue_Queue";
java.util.Hashtable env = new java.util.Hashtable();
env.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory");
env.put(javax.naming.Context.SECURITY_PRINCIPAL, "");
env.put(javax.naming.Context.SECURITY_CREDENTIALS, "");
jndiContext = new InitialContext(env);
queueConnectionFactory = (QueueConnectionFactory)jndiContext.lookup("jms/QueueConnectionFactory");
queue = (Queue) jndiContext.lookup(queueName);
queueConnection = queueConnectionFactory.createQueueConnection();
queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
queueSender = queueSession.createSender(queue);
message = queueSession.createObjectMessage();
System.out.println("Sending message");
I tried using iiop and rmi as well. It would give the same InvocationException. I am using j2sdkee1.4. I think something is wrong with the jms settings in the server. Please suggest me if u have already come across a problem similar to this.
Lasse Koskela
Posts: 11962
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried creating the InitialContext without parameters?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!