• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

JMS Client not working in JSP

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.PROVIDER_URL,"orb://cspl-pc-75:1050");
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);
queueConnection.start();
queueSender = queueSession.createSender(queue);
message = queueSession.createObjectMessage();
System.out.println("Sending message");
queueSender.send(message);
queueConnection.close();
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.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried creating the InitialContext without parameters?
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic