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 6849143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:57:13+00:00 2026-05-27T00:57:13+00:00

This one makes no sense to me because i am certain everything is there

  • 0

This one makes no sense to me because i am certain everything is there

This is what i get in the login form

Your login attempt was not successful, try again. Reason:
PreparedStatementCallback; SQL [SELECT user_name, user_password,
enabled, email_address, id, user_first_name, user_last_name FROM user
WHERE user_name = ?]; Column Index out of range, 8 > 7. ; nested
exception is java.sql.SQLException: Column Index out of range, 8 > 7.
.

The bean in applicationContext-security.xml file for the authentication

      <beans:bean id="customUserDetailsService" class="com.au.dealclick.implementations.CustomJdbcDaoImpl">
      <beans:property name="dataSource" ref="dataSource"/>
      <beans:property name="usersByUsernameQuery" value="SELECT user_name, user_password, enabled, email_address, id, user_first_name, user_last_name, city FROM user WHERE user_name = ?"/>
      <beans:property name="authoritiesByUsernameQuery" value="SELECT user_name , R.name FROM user U, roles R WHERE U.roles = R.Id AND user_name=?"/>
      </beans:bean>

This is the customJdbcDaoImpl.java file

package com.au.dealclick.implementations; 

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import java.util.List;
import javax.sql.DataSource;
import org.springframework.context.ApplicationContextException;
import org.springframework.jdbc.core.SqlParameter;
import org.springframework.jdbc.object.MappingSqlQuery;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl;
import org.springframework.security.core.authority.AuthorityUtils;
import com.au.dealclick.implementations.UserDetailsImplementation;

public class CustomJdbcDaoImpl extends JdbcDaoImpl {

private MappingSqlQuery usersByUsernameMapping;


@Override
protected void initDao() throws ApplicationContextException {
super.initDao();
this.usersByUsernameMapping = new CustomUsersByUsernameMapping(getDataSource());
}

@Override
protected List<UserDetails> loadUsersByUsername(String username) {
return usersByUsernameMapping.execute(username);
}

@Override
protected UserDetails createUserDetails(String username, UserDetails userFromUserQuery,
List<GrantedAuthority> combinedAuthorities) {
UserDetails u = super.createUserDetails(username, userFromUserQuery, combinedAuthorities);
UserDetailsImplementation user = new UserDetailsImplementation(u.getUsername(), u.getPassword(), u.isEnabled(), u.isAccountNonExpired(), u.isCredentialsNonExpired(), u.isAccountNonLocked(), u.getAuthorities());
UserDetailsImplementation customUserFromUserQuery = (UserDetailsImplementation) userFromUserQuery;
user.setEmailAddress(customUserFromUserQuery.getEmailAddress());
user.setId(customUserFromUserQuery.getId());
user.setFirstName(customUserFromUserQuery.getFirstName());
user.setLastName(customUserFromUserQuery.getLastName());
user.setCityId(customUserFromUserQuery.getCityId());
return user;
}

private class CustomUsersByUsernameMapping extends MappingSqlQuery {
protected CustomUsersByUsernameMapping(DataSource dataSource) {
super(dataSource, getUsersByUsernameQuery());
declareParameter(new SqlParameter(Types.VARCHAR));
compile();
}

protected Object mapRow(ResultSet rs, int rownum) throws SQLException {
String username = rs.getString(1);
String password = rs.getString(2);
boolean enabled = rs.getBoolean(3);
String email = rs.getString(4);
Long id = rs.getLong(5);
//Reference city
String firstName = rs.getString(6);
String lastName = rs.getString(7);
Long city = rs.getLong(8);
UserDetailsImplementation user = new UserDetailsImplementation(username, password, enabled, true, true, true, AuthorityUtils.NO_AUTHORITIES);
user.setEmailAddress(email);
user.setId(id);
user.setFirstName(firstName);
user.setLastName(lastName);
user.setCityId(city);
return user;
}
}
}

This is the userDetailsImplementation.java file

package com.au.dealclick.implementations; 

import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.Authentication;
import java.security.*;
import javax.persistence.*;
import java.lang.*;
import org.springframework.security.core.GrantedAuthority;
import java.util.*;
import com.au.dealclick.domain.Location;
public class UserDetailsImplementation extends User{

    public UserDetailsImplementation(String username, String password, boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired, boolean accountNonLocked, List<GrantedAuthority> authorities) {
      super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
    }
    public UserDetailsImplementation(String username, String password, boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired, boolean accountNonLocked, Collection<GrantedAuthority> authorities) {
      super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
    }
    private Long id;
    private String userFirstName;
    private String userLastName;
    private String emailAddress;
    private Long city;

    public Long getId() { return id; }
    public void setId(Long id) { this.id = id; }

    public String getFirstName() { return userFirstName; }
    public void setFirstName(String userFirstName) { this.userFirstName = userFirstName; }

    public String getLastName() { return userLastName; }
    public void setLastName(String userLastName) { this.userLastName = userLastName; }

    public Long getCityId() { return city; }
    public void setCityId(Long city) { this.city = city; }

    public String getEmailAddress() { return emailAddress; }
    public void setEmailAddress(String emailAddress) { this.emailAddress = emailAddress; }
}
  • 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-27T00:57:14+00:00Added an answer on May 27, 2026 at 12:57 am

    Is it possible that the applicationContext-security.xml file that you are running against is not the one that you have posted? It could be something to do with your build not copying the file to the runtime location for some reason.

    How is your running app deployed? e.g. WAR, WAR exploded, standalone jar etc. Try comparing the file in the runtime location with the source location.

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

Sidebar

Related Questions

I am exploring this and see if this one make sense. For instance I
I am not able to make a clear decision on this one. I am
This question is about the extent to which it makes sense unit testing. I’ve
I have this frame-based counter I use instead of the timer-class because everything in
How is it that tools like this one can make an ajax style call
This one has me kind of stumped. I want to make the first word
This one seems to be a simple problem, but I can't make it work
Every time in PHP when I make a variable such as this one: $date
This question might make one smile, really, HDD space is as cheap as dirt
Let's make this very easy. What I want: @array = qw/one two one/; my

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.