jms run

When i want to run a jms application with java <class> I get an error. But when I run it with vbj it works.

The error i get is:javax.naming.NoInitialContextException:

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

at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:643)

at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:246)

at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:283)

at javax.naming.InitialContext.lookup(InitialContext.java:350)

at test.FrameJms.jbInit(FrameJms.java:35)

at test.FrameJms.<init>(FrameJms.java:23)

This is the code :

TopicConnectionFactory factory;

javax.naming.Context context;

context = new javax.naming.InitialContext();

factory = (javax.jms.TopicConnectionFactory) context.lookup("example/MQueueFactory");

does anybody have an idea of how I can let is run

[1110 byte] By [wvtbg] at [2007-9-26 1:30:22]
# 1

Its obvious from the exception that your client is not able to find a setting for java.naming.factory.initial This is the environment property that specifies the class to use as the initial context.

Try running your application with the command line parameter -Djava.naming.factory.initial=<initial context class depending on your JNDI server>

I would recommend reading this http://www.javasoft.com/products/jms/tutorial/doc/client.html#1025459

neville_sequeira at 2007-6-29 1:28:21 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

I am not able to specify the parameter

-Djava.naming.factory.initial at command line because the class that needs to publish the JMS message is invoked because of an action performed by a webclient(The application is not started from a main method).

Is it possible to specify this parameter using properties or does anybody know another way how to solve this problem?

Sone at 2007-6-29 1:28:21 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3
I also want to start it from a application that isn.t started from the commandline. I also have to put it in an applet. And i'm using the Borland application server.So does anybody know what the i have to use with :java.naming.factory.initial wouter
wvtbg at 2007-6-29 1:28:21 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 4
You can also set a value for in the environment that is passed to the InitialContext constructor InitialContext(Hashtable environment).See http://java.sun.com/products/jndi/tutorial/basics/naming/index.html
neville_sequeira at 2007-6-29 1:28:21 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 5

In addition you can specify these parameters in a file that you call jndi.properties and put into your classpath.

example format for this file:

java.naming.factory.initial=com.sun.jndi.fscontext.RefFSContextFactory

java.naming.provider.url=file:/jnditutorial/

this example is for using Suns file based implementation of JNDI, a basing this in a directory called jnditutorial.

You can then call

Context ctx = new InitialContext() with no parameters - the method will look in the properties file.

It'd definitely be worth reading the tutorials though.

SteveWink at 2007-6-29 1:28:21 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 6

Just re-reading your original post - the reason it worked in vbj is that Borland App Server has a copy of jndi.properties in one of its .jar files, therefore it picks up the initial context parameters correctly there, whereas when you run it from the command line this file is not in your classpath.

SteveWink at 2007-6-29 1:28:21 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 7
In a jar called asrt.jar there was a jndi.properties file.And the com.inprise.j2ee.jndi.CtxFactory class. It now works fine.Thanks.
wvtbg at 2007-6-29 1:28:21 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...