• Post Reply Bookmark Topic Watch Topic
  • New Topic

JNDI Lookup  RSS feed

 
William Rice
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1.)
I develope on my local machine and I am trying to lookuo a organizational unit on my machine.
I am working with windows server 2000 and active directory. I have an OU named sales. And when I run the following program:
**************************************************
import javax.naming.*;
public class JNDILookupAny
{
public static void main(String[] args) {
if (args.length !=1) {
System.err.println ("Usage: JNDILookupAny JNDIname");
System.exit(1);
}
try {
Context ic = new InitialContext();
Object o = ic.lookup(args[0]);
System.out.println(args[0]+"="+0);
}
catch (NamingException ex) {
System.err.println("Nameexcp: "+ex);
System.exit(1);
}
catch (ClassCastException ex) {
System.err.println("classcast: "+ex);
System.exit(1);
}
}
}
*************************************************
I run the program with the following parameter.
java JNDILookupAny "ou=sales". I get the following error
javax.naming.NameNotFoundException: "ou=sales"
2.) My DSN is bill.zone.com and I set up a properties file withe the follwing lines:
java.naming.factory.inirial=com.zone.bill.naming.SerialInitContextFactory
java.naming.provider.url=localhost:1099
java.naming.factory.url.pkgs=com.zone.bill.naming
is this correct?
--------------------
William E. Rice
 
saravana kumar
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi william ,
i am new for this EJB tech.i am learning now.but i dont think u can simply call like
Object o = ic.lookup(args[0]);
have to write like
Object o= ic.lookup("java:comp/env/ejb/ur argumentname");
i am not sure. try this one. if anything wrong pls let me know where i did mistake.
 
Karan V Praba
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai ,
java:comp/env/ejb will not be avialable out side J2ee environment.So, u have to use JNDi name of u r component instead of rerence name.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!