Ok, for those interested, here's the real issue.

At some point in time (I don't know enough about tomcat to know when or why), before 
it Tomcat has your username (at least with my config files, but it looks common since 
JNDIRealm is checking for it too), authenticate is called with a null username.  Since 
the username is null, taking its length causes a null pointer exception.  I added a 
check, and now it works fine.

Justin

-----Original Message-----
From: Hart, Justin 
Sent: Tuesday, November 25, 2003 10:19 AM
To: Tomcat Users List
Subject: RE: Extending JNDIRealm


Read through the code, ran some example stuff.  What I'm doing in my implementation is 
fine.

Justin

-----Original Message-----
From: Hart, Justin 
Sent: Tuesday, November 25, 2003 9:31 AM
To: Tomcat Users List
Subject: RE: Extending JNDIRealm


Wait, reading the stack trace doesn't show anything like that.

No, that can't be the issue.

Justin

-----Original Message-----
From: Hart, Justin 
Sent: Tuesday, November 25, 2003 9:30 AM
To: Tomcat Users List
Subject: RE: Extending JNDIRealm


I *cough* didn't download the JNDIRealm code.  I'll go look into that.

Justin

-----Original Message-----
From: Tim Funk [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 25, 2003 9:28 AM
To: Tomcat Users List
Subject: Re: Extending JNDIRealm


Based on what I saw so far ...
In JNDIRealm authenticate(String, String) gets a DirContext and calls
authenticate(DirContext, String, String).

Your code snippet which I assume overrides, authenticate(DirContext, String, 
String) which calls super.authenticate(String, String).

Then ... super.authenticate(String, String) calls authenticate(DirContext, 
String, String) which you had overridden which is indirect recursion.

-Tim


Hart, Justin wrote:
> Ok, why?
> 
> What am I doing that should cause a stack overflow?
> 
> Justin
> 
> -----Original Message-----
> From: Tim Funk [mailto:[EMAIL PROTECTED]
> Sent: Monday, November 24, 2003 7:26 PM
> To: Tomcat Users List
> Subject: Re: Extending JNDIRealm
> 
> 
> Odd, based on what I see so far, I would expect it to crash with a 
> StackOverFlow exception.
> 
> -Tim
> 
> Hart, Justin wrote:
> 
>>Whoops, the code is actually as follows...
>>
>>No sure what's going on with this code...  I'm attempting to extend JNDIRealm so I 
>>can add a few features I need for my site, I have an interesting issue, however.
>>
>>If, I try this :
>>
>>    public Principal authenticate(DirContext context, String username, String 
>> credentials) throws NamingException {
>>              Principal authPrincipal = null;
>>              System.out.println(username);
>>              authPrincipal = super.authenticate(username, credentials);
>>              return authPrincipal;
>>      }
>>
>>username gets printed, and the system works properly
>>
>>However, if I try something akin to this
>>
>>    public Principal authenticate(DirContext context, String username, String 
>> credentials) throws NamingException {
>>              Principal authPrincipal = null;
>>              System.out.println(username.length());
>>              authPrincipal = super.authenticate(username, credentials);
>>              return authPrincipal;
>>      }
>>
>>It crashes with a null pointer exception.
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to