Indigo Blue <[EMAIL PROTECTED]> wrote:
>OK, I figured it out:
>Properties prop = new Properties();
> prop.put(Context.PROVIDER_URL,"spectrum.nschool.net");
>
>prop.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactor
>y");
> try {
> ctx = new InitialContext(prop);
> }
> catch (NamingException e) {
> System.out.println("Can't get context.");
> e.printStackTrace();
> }
There's a neater way, which will allow you to point your client at
different servers without rebuilding:
take one of the jndi.properties files from CVS, e.g. from
jboss/src/etc/conf, and put it in your client directory (assuming that
directory is on the classpath when you run the client - otherwise, any
other directory on the classpath).
In jndi.properties, you will find:
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=localhost
java.naming.factory.url.pkgs=org.jboss.naming
(You obviously want to change the url, the rest should be fine.)
In your client code, scrap all the stuff to do with Properties. Your
initial JNDI lookup should look like:
Context initial = new InitialContext();
ProductHome home =
(ProductHome)initial.lookup("MyProduct");
--
Justin Forder
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Problems?: [EMAIL PROTECTED]