You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by pgodot <pg...@temenos.com> on 2006/11/23 10:35:30 UTC

RE: JNDI Realm NPE

Hi tomcat list,

 

I'm trying to setup a JNDIRealm and I recieved a NPE if the user is not in
the LDAP Server:

 

java.lang.NullPointerException

            at
org.apache.catalina.realm.JNDIRealm.getPrincipal(JNDIRealm.java:1555)

            at
org.apache.catalina.realm.JNDIRealm.getPrincipal(JNDIRealm.java:1502)

            at
org.apache.catalina.realm.RealmBase.getPrincipal(RealmBase.java:1198)

            at
org.apache.catalina.realm.RealmBase.authenticate(RealmBase.java:436)

            at
org.apache.catalina.authenticator.SSLAuthenticator.authenticate(SSLAuthentic
ator.java:148)

            at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase
.java:490)

            at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126
)

            at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105
)

            at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:107)

            at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)

            at
org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:199)

            at
org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:282)

            at
org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:754)

            at
org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:684)

            at
org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java
:876)

            at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav
a:684)

            at java.lang.Thread.run(Thread.java:595)

 

This NPE arrived in the Realm and then tomcat doen't present any error page.

 

I checked quickly the JNDI realm code and so that:

 

   /**

     * Return the Principal associated with the given user name.

     */

    protected synchronized Principal getPrincipal(DirContext context,

                                                  String username)

        throws NamingException {

        

        User user = getUser(context, username);

        

        return new GenericPrincipal(this, user.username, user.password ,

                getRoles(context, user));

    }

 

But the getUser method return null when user is not found in the LDAP .

 

If the user is referenced in the LDAP all is ok !!!!

 

Thanks,

Phil




This email (and any attachments) contains confidential information, and is intended 
only for the named recipient. Distribution or copying of this email by anyone 
other than the named recipient is prohibited. If you are not the named or 
intended recipient, please notify TEMENOS or the sender immediately and 
permanently destroy this email (and any attachments) and all copies of it. No 
member of TEMENOS Group AG or any of its associated or affiliated companies is 
liable for any errors or omissions in the content or transmission of this 
email. Any opinions contained in this email are solely those of the author and, 
unless clearly indicated otherwise in writing, are not endorsed by any member 
of TEMENOS Group AG or any of its associated and affiliated companies.