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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:27:13+00:00 2026-06-14T04:27:13+00:00

I hope you can help me with this. I’m using Spring MVC (3.1.1) in

  • 0

I hope you can help me with this.

I’m using Spring MVC (3.1.1) in my web application, and am facing a strange situation.
I have this simple @Controller, that makes use of the ServicioUsuario Service, and works fine:

@Controller
@RequestMapping("/ajax")
public class ControladorAjax extends ControladorGenerico {

  @Autowired
  ServicioUsuario servicioUsuario;

  @RequestMapping("/check")
  public ResponseEntity<String> check(@RequestParam String email) {
    // Declarations and other operations omitted...
    // Use servicioUsuario
    servicioUsuario.doStuff();
    return response;
  }
}

However, if I remove the @Autowiring, and try to make Spring inject servicioUsuario as a parameter (i.e. by changing the method signature to: public ResponseEntity<String> check(@RequestParam String email, ServicioUsuario servicioUsuario)) the whole thing breaks, and I get this sort of exceptions in Tomcat’s log:

javax.servlet.ServletException: NestedServletException in java.lang.Thread.getStackTrace:: Request processing failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.package.ServicioUsuario]: Specified class is an interface

I have these interfaces:

com.package
  |-> Servicio.java (interface)
  |-> ServicioUsuario.java (interface that extends Servicio)

and these clases:

com.package.impl
  |-> ServicioImpl.java (implements Servicio)
  |-> ServicioUsuarioImpl.java (@Service("servicioUsuario") that extends ServicioImpl implements ServicioUsuario)

and configured Spring to scan both packages with:

<context:component-scan base-package="com.package
                                      com.package.impl" />

Why is Spring trying to instantiate the interface and not the implementing class? Is it something I’m doing wrong?

  • 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-14T04:27:15+00:00Added an answer on June 14, 2026 at 4:27 am

    According to 16.3.3.1 Supported method argument types of the official documentation, this is a complete list of what controller methods can take:

    • Request or response objects (Servlet API). […] for example ServletRequest or HttpServletRequest.

    • Session object (Servlet API): of type HttpSession.

    • org.springframework.web.context.request.WebRequest or org.springframework.web.context.request.NativeWebRequest.

    • java.util.Locale for the current request locale […]

    • java.io.InputStream / java.io.Reader for access to the request’s content. […]

    • java.io.OutputStream / java.io.Writer for generating the response’s content. […]

    • java.security.Principal containing the currently authenticated user.

    • @PathVariable annotated parameters for access to URI template variables. […]

    • @RequestParam annotated parameters for access to specific Servlet request parameters. […]

    • @RequestHeader annotated parameters for access to specific Servlet request HTTP headers. […]

    • @RequestBody annotated parameters for access to the HTTP request body. […]

    • @RequestPart annotated parameters for access to the content of a "multipart/form-data" request part. […]

    • HttpEntity<?> parameters for access to the Servlet request HTTP headers and contents. […]

    • java.util.Map / org.springframework.ui.Model / org.springframework.ui.ModelMap […]

    • org.springframework.web.servlet.mvc.support.RedirectAttributes […]

    • Command or form objects to bind request parameters to bean properties (via setters) or directly to fields, […]

    • org.springframework.validation.Errors / org.springframework.validation.BindingResult […]

    • org.springframework.web.bind.support.SessionStatus […]

    • org.springframework.web.util.UriComponentsBuilder […]

    As you can see, Spring beans are not on this (quite impressive) list. Why would you inject services via controller method? They never change. It’s enough to inject them once and assign them to a field.

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

Sidebar

Related Questions

I hope someone can help with this issue. I have a popup iframe using
I hope you can help. This has been confounding me for hours. I have
I hope some of you guys can help me with this problem.... I have
I hope you can help me. I have a web service that needs to
hope you can help me on this one, I'm currently using this: jQuery plugin:validation
Hope someone can help me with this.. I have a magento store up&running, via
I really hope someone can help on this because I'm learning cocoa and have
hope someone can help me with this! I've written a simple online 3d editor
I hope you can help me with this one. My application is monitoring a
Hope someone can help with this. I've been up and down the web and

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.