marbletravis
marbletravis

Reputation: 135

Tomcat not executing the correct realm

I am working on a tomcat 7 webapp that I recently inherited. We are working on migrating from Tomcat 5.5.

The webapp uses a tomcat realm to handle a combination of ldap/sql authentication.

When I define my context.xml as follows

<Context docBase="*******" reloadable="false">
    <Realm className="com.******.tomcat.auth.LdapSqlRealm"
       ****
     />
    <Resource name="jdbc/*****"
      auth="Container"
      type="javax.sql.DataSource"
      factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
      testWhileIdle="true"
      testOnBorrow="true"
      testOnReturn="false"
      validationQuery="SELECT 1"
      validationInterval="30000"
      timeBetweenEvictionRunsMillis="60000"
      maxActive="15"
      maxIdle="15"
      maxWait="30000"
      initialSize="10"
      removeAbandonedTimeout="60"
      removeAbandoned="true"
      logAbandoned="true"
      minEvictableIdleTimeMillis="60000"
      numTestsPerEvictionRun="2"
      jmxEnabled="true"
      jdbcInterceptors="org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;
        org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer"
      username="*****"
      password="*****"
      driverClassName="oracle.jdbc.driver.OracleDriver"
      url="*****"
    /></Context>

I can see my realm initializing in the logs, but when I go to authenticate (using basic) it doesn't use my realm.

If I define the realm in the server.xml file it works just fine.

Any thoughts on why I can't define it in the context.xml.

Our context.xml file is actually located in cont/Catalina/localhost/*****.xml

I have tried starting from scratch with simple realms, or extensions of RealmBase and they all do the same thing.

Thanks, Travis

Upvotes: 3

Views: 536

Answers (1)

marbletravis
marbletravis

Reputation: 135

Turns out that I had an extra <Context /> tag in my <Host /> tag in my server.xml which was messing up my context.xml file.

Little Santi tipped me off by suggesting a vanilla build of tomcat, which I didn't end up doing, but I did a compare of server.xml from the two and spotted the issue right away. Wish I had thought of it sooner.

Upvotes: 1

Related Questions