• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JMS and JNDI

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I am trying to connect to queues which may be on different MOM i.e. MQSeries, SonicMQ etc. I want to use a JNDI lookup to find queues.
I have read that InitialContext( ) can be created without properties (no-arg constructor) and in this case JNDI will read the vendor-specific JNDI properties from a special file in the classpath.
However no source code for this task was given, or what this 'special file' is(maybe properties file??).
Can anyone explain how this is done or even better show me some example code of how this is done?
Any help would be greatly appreciated!!
Thanks,
Patrick
 
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am not sure about
InitialContext ic= new InitialContext();
You must have to pass Hashtable/properties(ht) contains information about ContextFactory, Provider URL.
InitialContext ic= new InitialContext(ht);
Regards,
M.S.Raman.
 
Patrick ODonnell
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply.
If I have a properties file as follows:
# Default Java 2 SDK, Enterprise Edition 1.3 Reference Implementation Settings
Java2SdkEe13.properties.java.naming.factory.initial=com.sun.enterprise.naming.SerialInitContextFactory
Java2SdkEe13.properties.java.naming.factory.url.pkgs=com.sun.enterprise.naming
Java2SdkEe13.properties.queue.connectionfactory.name=QueueConnectionFactory
Java2SdkEe13.properties.queue.name=jms/Queue
Java2SdkEe13.properties.topic.connectionfactory.name=TopicConnectionFactory
Java2SdkEe13.properties.topic.name=jms/Topic
how would I set-up an initial context from this file?
Thanks,
Patrick.
 
Malli Raman
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am not sure about j2ee server.
But with reference to the following url:
http://forum.sun.com/thread.jsp?forum=8&thread=6761
Context Properties prop = new Properties();
prop.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.enterprise.naming.SerialInitContextFactory");
prop.put(Context.PROVIDER_URL, "localhost:1050");
prop.put(Context.SECURITY_AUTHENTICATION, "simple");
prop.put(Context.SECURITY_PRINCIPAL, "guest");
prop.put(Context.SECURITY_CREDENTIALS, "guest123");
Context initial = new InitialContext(prop);
************************************************
Then in the try catch block use the following code
try
{
initial.lookup("QueueConnectionFactory");// for Queues.
}
catch(NamingException ne)
{ }

Regards,
M.S.Raman.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic