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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:58:13+00:00 2026-05-16T01:58:13+00:00

When trying to autowire JdbcUserDetailsManager from Spring Security, I use following statement in appcontext.xml

  • 0

When trying to autowire JdbcUserDetailsManager from Spring Security, I use following statement in appcontext.xml (located separated from webapp):

 <bean class="org.springframework.security.provisioning.JdbcUserDetailsManager">
    <property name="dataSource" ref="dataSource"/>                                                                
</bean>

When running unit test all is fine. When starting my web app, which has it’s own appcontext.xml including the original appcontext.xml, I get an duplicate error:

No unique bean of type 
    [org.springframework.security.provisioning.JdbcUserDetailsManager] is defined:   
        expected single matching bean but found 2: 
    [org.springframework.security.provisioning.JdbcUserDetailsManager#0, 
        org.springframework.security.provisioning.JdbcUserDetailsManager#1]

How can I refine my two appcontext.xml in order to get both, the service layer tests and the webapp running respectively?

  • 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-16T01:58:14+00:00Added an answer on May 16, 2026 at 1:58 am

    Why do you need to include the JdbcUserDetailsManager in your web/servlet application context? The WebApplicationContext gets the main ApplicationContext as a parent “automatically” (if you configure it correctly.) See this IBM article for an example of setting contextConfigLocation so the web app knows where to find the main ApplicationContext.

    Or this example:

    contextConfigLocation
    /WEB-INF/main-application-config.xml

        <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>
        <servlet>
            <servlet-name>mine</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <init-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>/WEB-INF/web-application-config.xml</param-value>
            </init-param>
        </servlet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use Spring to inject a SLF4J logger into a class like
I'm trying to use Spring IoC with an interface like this: public interface ISimpleService<T>
I'm trying to combine Spring with Hibernate using Annotations and I'm getting the following
I'm trying to test the Autowire option like this: @ContextConfiguration(locations = { classpath:applnContext.xml })
I am trying to use autowire=autodetect.. In eclipse code suggest does not show me
I am trying to get a Java app using spring-security to talk to a
Trying to make a MySQL-based application support MS SQL, I ran into the following
Trying to create a QtRuby application, I get the following error: /usr/lib64/ruby/site_ruby/1.8/Qt/qtruby4.rb:2144: [BUG] Segmentation
Trying to honor a feature request from our customers, I'd like that my application,
I'm trying out Spring MVC 3.0 for the first time and like to make

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.