- It runs Fine.
- BUT when I do a Debug (F7 in netbeans) , It gives an exception in method initJMS() (code attached).
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
private void initJMS() throws JMSException { try { jndi = new InitialContext(); } catch(Exception e) { JOptionPane.showMessageDialog(null, e); } try { ConnectionFactory connectionFactory = (ConnectionFactory)jndi.lookup("jms/ConnectionFactory"); Queue queue = (Queue)jndi.lookup("jms/Queue"); connection = connectionFactory.createConnection(); session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); dest=(Destination)queue; producer = session.createProducer(dest); } catch(Exception e) { System.out.println(e); JOptionPane.showMessageDialog(null, e); } }
Ans :
Thanks for the tidbit. This is for GlassFish: https://glassfish.dev.java.net/javaee5/docs/DG/beanr.html. Can also see this: http://weblogs.java.net/blog/kalali/archive/2006/05/step_by_step_to_2.html.
Ans 1 :
Try this...
http://java.sun.com/products/jndi/tutorial/beyond/env/source.html
Apparently, my code is out in the car. But if you scroll to the bottom, you will see an example of putting value in environment using HashTable.
The approach I used was same as that, but instead of Context.Applet, I was using INITIAL_CONTEXT_FACTORY (http://java.sun.com/j2se/1.4.2/docs/api/javax/naming/Context.html). In my case I used the context factory for NDS, but you would just put in appropriate value as indicated as a fully qualified classpath to the context factory for your application.
No comments:
Post a Comment