-
-
2. Re: JMS problem
matrix1234 Nov 8, 2005 11:30 PM (in response to matrix1234)i opened your link and found..
How to ask for help
Do u want to teach me how to ask for help ?
see, if you dont know dont provide the answer.
I am a Jboss newbie. i just dont know what are classes needed for this initial context and blah blah..
what i have asked , the answer would be almost 3-4 code statements..not more than that.
if you are too stingy or dont want to share then just dont do it.
dont teach me ..how to ask for help or dont post th whole JBoss tutorial. -
3. Re: JMS problem
matrix1234 Nov 8, 2005 11:41 PM (in response to matrix1234)ohh i see you are
Chief Scientist
JBoss, Inc.
Sorry sir, please ignore my statements. i assumed you are another newbie and boasting.
sir, i did not find any useful material. will you please tell what exactly i should code to take the JNDI help from Jboss ?
i am trying to run a standalone JMS Helloworld program . -
4. Re: JMS problem
matrix1234 Nov 8, 2005 11:46 PM (in response to matrix1234)here is my story..
i downloaded openJMS . and tried to run my JMS client program. my client program has this code..properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.exolab.jms.jndi.InitialContextFactory"); properties.put(Context.PROVIDER_URL, "rmi://localhost:1099/"); Context context = new InitialContext(properties);
i a getting exception "org.exolab.jms.jndi.InitialContextFactory" ..not found !!.
i can assure you, my openJMS server is running.
So, i am planning to use JBOSS instead of openJMS. i have heard JBoss supports JMS.
will you please replace the above code statements if i were to use JBoss ?
Thank you -
5. Re: JMS problem
anders.hedstrom Nov 9, 2005 2:56 AM (in response to matrix1234)Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); env.put(Context.PROVIDER_URL, "jnp://localhost:1099"); env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); Context context = new InitialContext(env);
-
6. Re: JMS problem
matrix1234 Nov 9, 2005 4:40 AM (in response to matrix1234)thank you.
i have just one more question.
here is the steps..
1. i'll start Jboss from command line c:\jboss\bin\run.bat ==> this works.
2. i'll replace my client code with the code snippet you have provided.
3. now, should i run from command line ? or should i have to run it from Jboss deploy directory ?
here is my doubut. -
7. Re: JMS problem
matrix1234 Nov 9, 2005 4:43 AM (in response to matrix1234)env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL, "jnp://localhost:1099");
env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); // what is this ? -
8. Re: JMS problem
anders.hedstrom Nov 9, 2005 4:47 AM (in response to matrix1234)I don't really understand your question...
But you start JBoss using the run.bat file located in the bin directory. If you don't supply any arguments, JBoss will start the default configuration, if you supply run.bat -c all, JBoss will start the all configuration....and so on... -
9. Re: JMS problem
anders.hedstrom Nov 9, 2005 4:51 AM (in response to matrix1234)Constant that holds the name of the environment property for specifying the list of package prefixes to use when loading in URL context factories. The value of the property should be a colon-separated list of package prefixes for the class name of the factory class that will create a URL context factory. This property may be specified in the environment, an applet parameter, a system property, or one or more resource files. The prefix com.sun.jndi.url is always appended to the possibly empty list of package prefixes.
The value of this constant is "java.naming.factory.url.pkgs". -
10. Re: JMS problem
matrix1234 Nov 9, 2005 5:15 AM (in response to matrix1234)"anders.hedstrom" wrote:
I don't really understand your question...
But you start JBoss using the run.bat file located in the bin directory. If you don't supply any arguments, JBoss will start the default configuration, if you supply run.bat -c all, JBoss will start the all configuration....and so on...
actuallly, i am trying to runimport java.util.Hashtable; import javax.jms.JMSException; import javax.jms.Queue; import javax.jms.QueueConnection; import javax.jms.QueueConnectionFactory; import javax.jms.QueueSender; import javax.jms.QueueSession; import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; public class QueueSend { public static void main(String[] args) { try { // create a JNDI context Hashtable properties = new Hashtable(); properties.put(Context.INITIAL_CONTEXT_FACTORY,"org.exolab.jms.jndi.InitialContextFactory"); properties.put(Context.PROVIDER_URL,"rmi://localhost:1099/"); Context context = new InitialContext(properties); // retrieve queue connection factory QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory)context.lookup("JmsQueueConnectionFactory"); // create a queue connection QueueConnection queueConnection = queueConnectionFactory.createQueueConnection(); // create a queue session // set transactions to false and set auto acknowledgement of receipt of messages QueueSession queueSession = queueConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE); // retrieve queue Queue queue = (Queue)context.lookup("queue1"); // create a queue sender and associate to the retrieved queue QueueSender queueSender = queueSession.createSender(queue); // send a message to the queue TextMessage message = queueSession.createTextMessage(); message.setText("Hello there."); queueSender.send(message); System.out.println("Sample application writing message to queue."); // clean up queueSender.close(); queueSession.close(); queueConnection.close(); } catch (NamingException e) { e.printStackTrace(); } catch (JMSException e) { e.printStackTrace(); } } }
i am running from command line. do i have deploy this code ?
can not i run from the command line ? -
11. Re: JMS problem
matrix1234 Nov 9, 2005 5:18 AM (in response to matrix1234)"anders.hedstrom" wrote:
I don't really understand your question...
But you start JBoss using the run.bat file located in the bin directory. If you don't supply any arguments, JBoss will start the default configuration, if you supply run.bat -c all, JBoss will start the all configuration....and so on...
do you mean, i should start my jboss with run.bat -c all option so my jms will work ?
after that i can run it from command line ? -
12. Re: JMS problem
anders.hedstrom Nov 9, 2005 5:59 AM (in response to matrix1234)Matrix1234 wrote:
do you mean, i should start my jboss with run.bat -c all option so my jms will work ?
no, the default configuration has the JMS service deployedMatrix1234 wrote:
i am running from command line. do i have deploy this code ?
noMatrix1234 wrote:
can not i run from the command line ?
yes -
13. Re: JMS problem
matrix1234 Nov 9, 2005 7:26 AM (in response to matrix1234)thank you for the excellent answers.
you must be a JBoss guru.
i'll check it out.
regards -
14. Re: JMS problem
matrix1234 Nov 9, 2005 7:49 AM (in response to matrix1234)here is the updatd code with Jboss JNDI-JMS service...its not working!!
import java.util.Hashtable; import javax.jms.JMSException; import javax.jms.Queue; import javax.jms.QueueConnection; import javax.jms.QueueConnectionFactory; import javax.jms.QueueSender; import javax.jms.QueueSession; import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; public class QueueSend { public static void main(String[] args) { try { // create a JNDI context Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); env.put(Context.PROVIDER_URL, "jnp://localhost:1099"); env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); Context context = new InitialContext(env); // retrieve queue connection factory QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory)context.lookup("JmsQueueConnectionFactory"); // create a queue connection QueueConnection queueConnection = queueConnectionFactory.createQueueConnection(); // create a queue session // set transactions to false and set auto acknowledgement of receipt of messages QueueSession queueSession = queueConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE); // retrieve queue Queue queue = (Queue)context.lookup("queue1"); // create a queue sender and associate to the retrieved queue QueueSender queueSender = queueSession.createSender(queue); // send a message to the queue TextMessage message = queueSession.createTextMessage(); message.setText("Hello there."); queueSender.send(message); System.out.println("Sample application writing message to queue."); // clean up queueSender.close(); queueSession.close(); queueConnection.close(); } catch (NamingException e) { e.printStackTrace(); } catch (JMSException e) { e.printStackTrace(); } } }
javac -classpath .;e:\j2ee.jar; QueueSend.java ===>compiled fine.
java -classpath .;e:\2ee.jar; QueueSendjavax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interf aces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: o rg.jnp.interfaces.NamingContextFactory] at javax.naming.spi.NamingManager.getInitialContext(Unknown Source) at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source) at javax.naming.InitialContext.init(Unknown Source) at javax.naming.InitialContext.<init>(Unknown Source) at QueueSend.main(QueueSend.java:26) Caused by: java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFac tory at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source) ... 5 more
WHATS WRONG ????
my Jboss server is up ...still i am getting this error ?