beginner need help on javax.naming.directory

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();
scope.setSearchScope(SearchControls.SUBTREE_SCOPE);
NamingEnumeration result = context.search(BASE, FILTER, scope);
SearchResult  srchresult = (SearchResult) result.next();
System.out.println("dn: " +  srchresult.getName() + ","  + BASE + "\n");
Attributes attrs = srchresult.getAttributes();
NamingEnumeration ne = attrs.getAll();
while (ne.hasMoreElements())
{
      Attribute attr = (Attribute) ne.next();
      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: MRDSServer.java 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 !
Wonder19Asked:
Who is Participating?
 
basicinstinctConnect With a Mentor Commented:
0
All Courses

From novice to tech pro — start learning today.