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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:23:15+00:00 2026-06-17T20:23:15+00:00

I have multiple http blocks in my spring security configuration. This is allowed since

  • 0

I have multiple http blocks in my spring security configuration. This is allowed since Spring Security version 3.1. The problem occurs when my SpringSocial config attempts to auto inject a RequestCache object. I get the following error: No qualifying bean of type [org.springframework.security.web.savedrequest.RequestCache] is defined: expected single matching bean but found 3. If I remove the reference in Java code to the auto wired RequestCache object, having three http blocks in my xml configuration is ok. What is the best approach to fix this error? Is there some way to autowire the correct RequestCache?

The xml http blocks:

<http pattern="/oauth/token"...>
</http>

<http pattern="/something/**...>
</http>

<http use-expressions="true"...>
</http>

In Java Config, there is a reference to an autowired RequestCache:

@Bean
public ProviderSignInController providerSignInController(RequestCache requestCache) {
    return new ProviderSignInController(connectionFactoryLocator(), usersConnectionRepository(), new SimpleSignInAdapter(requestCache, userService));
} 

Neither of these cause a problem by themselves. However, having multiple http blocks and an autowired RequestCache causes: “No qualifying bean of type [org.springframework.security.web.savedrequest.RequestCache] is defined: expected single matching bean but found 3”

Can anyone help me with a way to configure this correctly?

  • 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-17T20:23:16+00:00Added an answer on June 17, 2026 at 8:23 pm

    The issue is that each block creates its own instance of RequestCache. Using a new instance, will still work between the blocks since the default implementation of RequestCache uses the same data store (i.e. the HttpSession). However, when you try to use autowiring it does not know which instance to use. Instead, you create your own instance of HttpSessionRequestCache and use it (just as the http blocks do). For example:

    @Bean
    public ProviderSignInController providerSignInController() {
        RequestCache requestCache = new HttpSessionRequestCache();  
        return new ProviderSignInController(connectionFactoryLocator(), usersConnectionRepository(), new SimpleSignInAdapter(requestCache, userService));
    }
    

    An alternative that should work is to specify the RequestCache in configuration and reuse the same instance using the request-cache element. For example:

    <bean:bean class="org.springframework.security.web.savedrequest.HttpSessionRequestCache"
            id="requestCache" />
    
    <http pattern="/oauth/token"...>
        <request-cache ref="requestCache"/>
    </http>
    
    <http pattern="/something/**...>
        <request-cache ref="requestCache"/>
    </http>
    
    <http use-expressions="true"...>
        <request-cache ref="requestCache"/>
    </http>
    

    Since there is a single RequestCache instance, you can use your existing Java Config (i.e. autowire the RequestCache). Note that you could just as easily create the RequestCache in Java Config instead of in XML if you desire.

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

Sidebar

Related Questions

I have a Perl code that use threads and HTTP::Async with multiple outbound IP
I have multiple pages that have this pattern: <iframe frameborder =0 src=[someURL] width=100% height=900>
I am new to WPF. I have this code <Window x:Class=ElementBinding.MultipleBindings xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml Title=MultipleBindings
I have implemented following async blob upload method to upload multiple blocks. var container
The issue is this: I have a Spring Batch job with a single step.
I have an address form for multiple addresses. http://jsfiddle.net/VAs5r/6/ When the form is loaded,
I have multiple ajax requests with javascript code as response, and I need to
I have multiple projects which are to be hosted together in a Tomcat container,
I have multiple UpdatePanels on a webpage, one inside UserControl (Purple ColorBox as show
I have multiple forms for lots of products on my page and want to

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.