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

  • Home
  • SEARCH
  • 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 8231843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:37:48+00:00 2026-06-07T17:37:48+00:00

I am using Spring Security 3.1 to authenticate users for a website. When a

  • 0

I am using Spring Security 3.1 to authenticate users for a website. When a login fails because spring security is unable to connect to the database, I get the following statement in my log:

2012-07-12 11:42:45,419 [ajp-bio-8009-exec-1] DEBUG      org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter - Authentication request failed: org.springframework.security.authentication.AuthenticationServiceException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Connections could not be acquired from the underlying database!

My question is, why is this a DEBUG statement instead of an ERROR? I have to wade through a whole lot of debug statements just to find the actual error.

EDIT

Here is my authentication manager:

<bean id="securityDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="java:comp/env/securityDS"/>
    <property name="resourceRef" value="true"/>
</bean>

<bean id="encoder" class="org.springframework.security.crypto.password.StandardPasswordEncoder" />

<security:authentication-manager>
    <security:authentication-provider>
        <security:password-encoder ref="encoder" />
        <security:jdbc-user-service 
            data-source-ref="securityDataSource"
            authorities-by-username-query="SELECT username, authority FROM login WHERE username = ?"
            users-by-username-query="SELECT username, password, enabled FROM login WHERE username = ?"
        />        
    </security:authentication-provider>
</security:authentication-manager>
  • 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-06-07T17:37:50+00:00Added an answer on June 7, 2026 at 5:37 pm

    That message is printed out in AbstractAuthenticationProcessingFilter.unsuccessfulAuthentication:

    protected void unsuccessfulAuthentication(HttpServletRequest request, HttpServletResponse response,
            AuthenticationException failed) throws IOException, ServletException {
        SecurityContextHolder.clearContext();
    
        if (logger.isDebugEnabled()) {
            logger.debug("Authentication request failed: " + failed.toString());
    

    There are a number of ways an authentication can fail, including based on user input. For example, in AbstractUserDetailsAuthenticationProvider.authenticate, a BadCredentialsException could be thrown if the username is not found:

            try {
                user = retrieveUser(username, (UsernamePasswordAuthenticationToken) authentication);
            } catch (UsernameNotFoundException notFound) {
                logger.debug("User '" + username + "' not found");
    
                if (hideUserNotFoundExceptions) {
                    throw new BadCredentialsException(messages.getMessage(
                            "AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"));
                } else {
                    throw notFound;
                }
            }
    

    Since there could be legitimate reasons why an authentication can fail, it doesn’t make sense for AbstractAuthenticationProcessingFilter to log an error. If there is a system error the error should have been logged further downstream.

    I suspect that the problem is in DaoAuthenticationProvider (see my comment inline):

    protected final UserDetails retrieveUser(String username, UsernamePasswordAuthenticationToken authentication)
            throws AuthenticationException {
        UserDetails loadedUser;
    
        try {
            loadedUser = this.getUserDetailsService().loadUserByUsername(username);
        }
        catch (DataAccessException repositoryProblem) {
            // *** ERROR SHOULD BE LOGGED HERE ***
            throw new AuthenticationServiceException(repositoryProblem.getMessage(), repositoryProblem);
        }
    

    Perhaps an error should be logged here – you can log a JIRA with Spring to request that. Though maybe they are assuming that everyone is going to provide a custom UserDetailsService and will catch/log their own exceptions there. If you are using JdbcDaoImpl it does not. I think JdbcDaoImpl is intended to be an example and is not robust. Per the docs:

    The good news is that we provide a number of UserDetailsService
    implementations, including one that uses an in-memory map
    (InMemoryDaoImpl) and another that uses JDBC (JdbcDaoImpl). Most users
    tend to write their own, though, with their implementations often
    simply sitting on top of an existing Data Access Object (DAO) that
    represents their employees, customers, or other users of the
    application.

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

Sidebar

Related Questions

I am trying to authenticate users to an Active Directory Instance using spring security,
I'm using Spring Security 3.04 to authenticate the users of my system using 3
We are using spring security to authenticate users from LDAP in our application. The
I'm using Spring Security 3 and my ApplicationContext-Security.xml specifies <form-login login-page=/genesis default-target-url=/diagnostics/start-diagnostics authentication-failure-url=/genesis?authfailed=true authentication-success-handler-ref=customTargetUrlResolver/>
I'm using Spring Security 3.0.7 How can I get with java code the access
I am trying to programatically validate a user login/pass using Spring Security, so I
Is it possible, using spring security plugin 0.5.3 with Grails 1.2.1, to authenticate a
I'm using Spring Security and I would like to know which users are currently
I am trying to get a Java app using spring-security to talk to a
I'm trying to use a authenticate with an Active directory using Spring Security 3.1.

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.