Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1027809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:17:29+00:00 2026-05-16T12:17:29+00:00

I develop a web application for Tomcat 6, and I’m face to face with

  • 0

I develop a web application for Tomcat 6, and I’m face to face with a problem I don’t know how to resolve. Let’s consider the following small scenario. Imagine that it’s required to authenticate users not just by user and password, the authentication is only granted if some extra conditions are true (e.g. user, password, and his IP address matches). As far I understood, Tomcat introduced the concept of realms. A simple JDBCRealm was enough for the application, because the user and password pair was checked only until the moment. Now it’s required to check the IP address too. I have written a simple test class that extends the JDBCRealm class:

package security;

import org.apache.catalina.realm.JDBCRealm;
import org.apache.log4j.Logger;

import java.security.Principal;
import java.sql.Connection;

public class ApplicationRealm extends JDBCRealm {

    protected final Logger logger = Logger.getLogger(this.getClass());

    @Override
    public synchronized Principal authenticate(Connection connection, String userName, String credentials) {
        logger.info("custom realm test, the authentication will be failed just for testing");
        return null;
    }

}

And then I have tried to bind this realm class using the context.xml:

<?xml version="1.0" encoding="UTF-8"?>
<Context>
    <Realm className="security.ApplicationRealm" connectionName="${user}" connectionPassword="${password}"
        connectionURL="${url}${database}" debug="99" driverName="${driver}" roleNameCol="role" userCredCol="pw"
        userNameCol="login" userRoleTable="users_roles" userTable="users"/>
</Context>

The deployment of the web application succeeds, but when I try to access the login page, Tomcat returns a 404 page (I suspect the root of the problem is the className attribute in the Realm node):

HTTP Status 404 -
type Status report
message
description The requested resource () is not available.
Apache Tomcat/6.0.24

How can I bind a custom JDBCRealm descendant in context.xml? Maybe I’m totally wrong trying to use the JDBCRealm for this, but I can’t see the correct solution anyway.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T12:17:29+00:00Added an answer on May 16, 2026 at 12:17 pm

    Incorrect deployment of the realm was the cause of the problem. Moreover, a custom realm is not suitable here. The best way of checking the IP-address is writing a custom form authenticator that have access to the HTTP request. Changing the form authenticator in the web.xml, and deploying it allowed exactly what I needed. It also eliminates the requirement to check IP-address on every request, because secure resources are hidden behind the authorization “wall” – this means if the authorization is granted, it also means that the IP was valid. Thanks to JoseK for pointing a good solution. I was just confused a little with the concept of realms in Tomcat.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to develop a web application, like an online scheduler. (Yes I know
I develop a web application that let users to upload files like images and
I am using jsp to develop a web application...using tomcat server... I am facing
Does anyone know if it exists a Web IDE allowing to develop web application
I need to develop a web application with the following requirements: Desktop like UI
I develop a web application using eclipse, maven and tomcat container. My web app
We have the following scenario with our project: A core web application packaged as
Is it safe now to develop web application with HTML 5 specifications? or should
I try do develop a web application with ExtJs 4.0. On startup the application
I should to develop a web-application in php for a firm, and I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.