beginner need help on

Posted on 2006-05-19
Last Modified: 2010-03-31
I minic the structure of a LDIF file and prepared a directory file named directory.txt - I read the whole file and pretend the file is a LDAP file. I want to use InitialDirContext object to search the file ...

bReader = new BufferedReader(new InputStreamReader(new FileInputStream("ResourseDirectory.txt")));
String line = "";
String record = "";
while((line = bReader.readLine()) != null) {
      record = record + line;
Hashtable resourse = new Hashtable( );
resourse.put(Context.INITIAL_CONTEXT_FACTORY, record);
DirContext context = new InitialDirContext(resourse);
SearchControls scope = new SearchControls();
NamingEnumeration result =, FILTER, scope);
SearchResult  srchresult = (SearchResult);
System.out.println("dn: " +  srchresult.getName() + ","  + BASE + "\n");
Attributes attrs = srchresult.getAttributes();
NamingEnumeration ne = attrs.getAll();
while (ne.hasMoreElements())
      Attribute attr = (Attribute);
      String attrname =  attr.getID() + ": ";
      Enumeration values = attr.getAll();
      while ( values.hasMoreElements()) {
            System.out.println( attrname + values.nextElement() );

But I have this error when I compiled the file:
Note: uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

Then I have the following erroir when I ran the file:
Exception: javax.naming.NoInitialContextException: Cannot instantiate class: dn:

Please HELP!  Ready appreicate any help !
Question by:Wonder19
    1 Comment
    LVL 23

    Accepted Solution


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
    Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
    Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
    This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now