• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

simple JMS example.

 
hasan khan
Ranch Hand
Posts: 223
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am trying to execute this simple example SimpleQueueSender.java from the tutorial provided at http://java.sun.com/products/jms/tutorial/1_3_1-fcs/doc/client.html#1027210

in this example it is creating empty initial context;

jndiContext = new InitialContext();

with empty InitialContext i got (javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial)


so i have modified it to

Properties prop = new Properties();
prop.setProperty(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
prop.setProperty(Context.PROVIDER_URL, "t3://192.168.3.91:7001");
jndiContext = new InitialContext(prop);



after making this changes and looking up for

queueConnectionFactory = (QueueConnectionFactory) jndiContext.lookup("QueueConnectionFactory"); // here it is returning weblogic.jms.common.DestinationImpl.classs

i am still getting java.lang.ClassCastException


i have configured weblogic 8.1 and created new JMS server and created JMSQueue named 'QueueConnectionFactory' and JNDI name 'jndi_QueueConnectionFactory'


what else do i need to add or change to my code or environment

also tell me is this
Context.INITIAL_CONTEXT_FACTORY = "weblogic.jndi.WLInitialContextFactory" right value
******************************************************************************************
 
Masoud Kalali
Author
Ranch Hand
Posts: 531
Java Mac OS X Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
In case that you are unsing a Sun application server version ,you are not using a correct initial context factory class.
here i explained how you can develop and test an end to end jms sample.
hope it helps.

http://weblogs.java.net/blog/kalali/archive/2006/05/step_by_step_to.html
http://weblogs.java.net/blog/kalali/archive/2006/05/step_by_step_to_2.html
one for remote client and one for client and server in same jvm(local client).
 
hasan khan
Ranch Hand
Posts: 223
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the reply,
apart from adding the propertiesthe example provided is fine, the example only require to 1 JMS connection factory and 1 JMS Queue in weblogic server.
[ September 04, 2006: Message edited by: hasaN khaN ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic