Re: println inside catch throwing Nullpointerexception?
On Nov 12, 2:08 pm, Lew <l...@lewscanon.com> wrote:
oh...@cox.net wrote:
println("The error was: " + e);
Incidentally, what println() method is this? You don't show us enough of the
class to see how println() is defined. Undoubtedly the error is in the
implementation of the println() method.
Inevitably, the problem is in the part of the code that you don't show, unless
you provide an SSCCE:
<http://www.physci.org/codes/sscce.html>
Please provide an SSCCE.
--
Lew
This post contains a request for an SSCCE to make it possible to answer the
OP's question.
Hi,
Sorry, I am trying to help out a colleague with this problem. Here's
a (hopefully) more complete snippet which I got:
try
{ // outer try
System.out.println("Connecting to [" + dsType + "] server: [" + dsHost
+ ":" + ("" + dsPort) + "]");
ld.connect(dsHost, dsPort);
LDAPSearchResults results = ld.search(baseDN, searchScope,
searchFilter, getAttributes, false);
if (!results.hasMoreElements())
{
return "";
}
while (results.hasMoreElements()) // loop, looking for all
returned entities
{
LDAPEntry findEntry = null;
try
{ // inner try
findEntry = results.next(); // get next entity returned by
LDAP server
LDAPAttribute attribute = findEntry.getAttribute(dsUserAtr);
Enumeration enumValues = attribute.getStringValues(); // put
attribute values into an Enumeration
if (!enumValues.hasMoreElements())
{
System.out.println("** ERROR **: enumValues.hasMoreElements() is
false ==> found match to certificate Subject and found desired
attribute, but attribute had no values...");
System.out.println("** ERROR **: -> So, will now return
indication that authentication failed...");
return "";
}
returnString = (String)enumValues.nextElement(); // move 1st
attribute value into returnString
numMatches++; // increment count of matches for this search
System.out.println("found match, returned string #(" + numMatches +
") = [" + returnString + "]");
} // end inner try
catch (LDAPReferralException e)
{
System.out.println("LDAP search failed ...");
System.out.println("LDAPReferralException = [" + e + "]"); <<--We
think Nullpointerexception being thrown here...
return "";
}
} // end while
System.out.println("LDAP search found [" + numMatches + "]
matches");
System.out.println("Disconnecting from LDAP server");
ld.disconnect();
} // end outer try
catch (LDAPException e)
{
System.out.println("** ERROR **: Failed ...");
System.out.println("** ERROR **: -> LDAPException = [" + e +
"]");
return "";
}