-
1. Re: How to compile & run manually Interest example
sgturner May 12, 2002 10:25 PM (in response to khdam)I suggest that you read up on JNDI. If you do this:
Context jndiContext = new InitialContext();
Object ref = jndiContext.lookup("interest/Interest");
then the InitialContext is trying to get init info from System.properties. Your exception makes clear that it can not find the info it needs. There are at least 2 ways to solve this. One is to pass the required info as system properties in the command line of your main. The other is to specify the info explicitly in the code:
Properties props = new Properties();
props.put (Context.PROVIDER_URL,
"jnp://localhost:1099");
props.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
Context jndiContext = new InitialContext(props);
Object ref = jndiContext.lookup("interest/Interest");
Of course replace localhost above, with whatever is appropriate for your environment.
This is an excellent book on JNDI:
http://www.amazon.com/exec/obidos/ASIN/0201705028/qid=1021256685/sr=1-2/ref=sr_1_2/103-4964161-8897410