Avatar billede fredand Forsker
31. januar 2006 - 16:38 Der er 1 løsning

Why doesn't my JMS app work?

Hello!

I need some help or advise with JMS.

I have test the sample application at:
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JMS5.html#wp81077

If I run it like they suggest like:
appclient -client SimpleProducer.jar jms/Queue 3
...It works perfect

But if I try to run it like:
java SimpleProducer jms/Queue 3
I get this exception:
JNDI API lookup failed: javax.naming.NoInitialContextException: Need to specify
class name in environment or system property, or as an applet parameter, or in a
n application resource file:  java.naming.factory.initial

I guess that the first way to start the app defines some context that I do not get in the second way to start it.

Do you know any nice way to setup the context or any other resources programatically that I need to be able to start the app in the second way?

BTW
If you follow the example like I did from the url above, the downloadable code uses "jms/JupiterConnectionFactory" but the description tell you to set it like "jms/ConnectionFactory". So be sure you use the same JNDI Name.

Best regards
Fredrik
Avatar billede fredand Forsker
01. februar 2006 - 10:04 #1
I guess I just need to specify:
java.naming.factory.initial=com.sun.jndi.ldap.LdapCtxFactory
in a jndi.properties file, loaded in the code and passed to the context, pointed from the classpath or set from System.setProperty();

Best regards
Fredrik
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester