I am trying to use ApacheDS 1.5 with Tomcat 5.5.17.

 

I first set up ApacheDS as a standalone appliation and set up the
following

<Realm> in the Tomcat server.xml file:

 

      <Realm className="org.apache.catalina.realm.JNDIRealm" debug="99"

             connectionName="uid=admin,ou=system"

             connectionPassword="secret"

             connectionURL="ldap://localhost:10389";

             digest="SHA"

             allRolesMode="authOnly"

             userPassword="userPassword"

             userPattern="uid={0},ou=accounts,dc=test,dc=org"

             roleBase="ou=groups,dc=test,dc=org"

             roleName="cn"

             roleSearch="(uniqueMember={0})"

      />

 

I start ApacheDS, then Tomcat, and things work just fine - my web
application

uses FORMS authentication and it goes through ApacheDS as expected.

 

I then embedded ApacheDS in my web application by implementing
ServletContextListener

so that it starts on contextInitialized and stops on contextDestroyed -
when

my web application starts and stops..

 

Now that ApacheDS was embedded, I just started Tomcat directly (without
starting

ApacheDS standalone). Tomcat seemed to hang there as there didn't appear
to be

any ApacheDS running. This makes sense as Tomcat starts running *before*
the

web application does - so this won't work.

 

Realizing this, it seemed to make sense to put my <Realm> in the 

META-INF/context.xml file of my web application. What I have read leads
me

to believe that this is the correct solution. So I moved the <Realm>
from 

the server.xml to the context.xml and tried again.

 

It still doesn't work. From the logging, I can see that ApacheDS is
being

started. But when I try to log in using FORMS authentication from my
login

page, it doesn't appear that the <Realm> from my context.xml is being
used

at all.  In fact, I get this exception in the Tomcat log:

 

     [java] May 15, 2009 4:05:12 PM org.apache.catalina.realm.JAASRealm
authenticate

     [java] SEVERE: Unexpected error

     [java] java.lang.SecurityException: Unable to locate a login
configuration

     [java]     at
com.sun.security.auth.login.ConfigFile.<init>(ConfigFile.java:93)

     [java]     at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(NativeMethod)

     [java]     at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorA
ccessorImpl.java:39)

     [java]     at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingCons
tructorAccessorImpl.java:27)

     [java]     at
java.lang.reflect.Constructor.newInstance(Constructor.java:513)

     [java]     at java.lang.Class.newInstance0(Class.java:355)

     [java]     at java.lang.Class.newInstance(Class.java:308)

     [java]     at
javax.security.auth.login.Configuration$3.run(Configuration.java:246)

     [java]     at java.security.AccessController.doPrivileged(Native
Method)

     [java]     at
javax.security.auth.login.Configuration.getConfiguration(Configuration.j
ava:241)

     [java]     at
javax.security.auth.login.LoginContext$1.run(LoginContext.java:237)

     [java]     at java.security.AccessController.doPrivileged(Native
Method)

     [java]     at
javax.security.auth.login.LoginContext.init(LoginContext.java:234)

     [java]     at
javax.security.auth.login.LoginContext.<init>(LoginContext.java:403)

     [java]     at
org.apache.catalina.realm.JAASRealm.authenticate(JAASRealm.java:347)

     [java]     at
org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAut
henticator.java:257)

     [java]     at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authenticator
Base.java:416)

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

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

     [java]     at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541
)

 

Now this really confuses me.  Why is it using JAASRealm?  That's not
configured

in either my server.xml or my context.xml file.  I would have expected
it to

use the realm (JNDIRealm) that I defined in my context.xml.

 

I can't see what I am doing wrong here. Can anyone help?

 

Thanks,

 

-- Greg

 


__________________________________________________________________________________________________________________
DISCLAIMER:"The information contained in this message and the attachments (if 
any) may be privileged and confidential and protected from disclosure. You are 
hereby notified that any unauthorized use, dissemination, distribution or 
copying of this communication, review, retransmission, or taking of any action 
based upon this information, by persons or entities other than the intended 
recipient, is strictly prohibited. If you are not the intended recipient or an 
employee or agent responsible for delivering this message, and have received 
this communication in error, please notify us immediately by replying to the 
message and kindly delete the original message, attachments, if any, and all 
its copies from your computer system. Thank you for your cooperation." 
________________________________________________________________________________________________________________

Reply via email to