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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:28:44+00:00 2026-06-03T13:28:44+00:00

I have a Restful design for my Maven project, a domain layer with a

  • 0

I have a Restful design for my Maven project, a domain layer with a user class, a data layer with the services with CRUD functionality and a web layer with the controller classes. But when I run the project I get the errors below:

javax.servlet.ServletException: Servlet.init() for servlet appServlet threw exception
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
........
java.lang.Thread.run(Thread.java:680)   


root cause

   org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userController': Injection of autowired dependencies failed; nested              
   exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: ........service.UserService org.
   bk.samples.mvc.UserController.userService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [se. 
   datalayer.guards.service.UserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency 
   annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
   org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) ..........

root cause

org.springframework.beans.factory.BeanCreationException: Could not autowire field: .........service.UserService 
org.bk.samples.mvc.UserController.userService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type 
[se.datalayer.guards.service.UserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency 
annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}   ..........

root cause

org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [.........service.UserService] found for dependency: 
expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: 
{@org.springframework.beans.factory.annotation.Autowired(required=true)}
    org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:924)
    org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:793) .......

Then I removed the @Autowired annotation but got the error below:

    org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.NullPointerException
        org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894)
        org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

    root cause

    java.lang.NullPointerException
        org.bk.samples.mvc.UserController.allUsers(UserController.java:32)
        sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)..........  

My userController class is:

@Controller
@RequestMapping(value="/")
public class UserController
{
    @Autowired
    UserService userService;

    @RequestMapping(value="/users", method=RequestMethod.GET)
    public ModelAndView allUsers()
    {

    ModelAndView mvd= new ModelAndView();
    Collection<User> allUsers= new ArrayList<User>();
    allUsers= userService.findAllUsers();
    System.out.println(allUsers);
    mvd.addObject("allUsers", allUsers);
    return mvd;   
    }
}           

I don’t know what caused the problem and I would appreciate any help.

  • 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-03T13:28:46+00:00Added an answer on June 3, 2026 at 1:28 pm

    It has nothing to do with Maven. You have problems with your Spring configuration. It’s telling you that you have no Spring bean of type UserService defined, so it can’t create your controller bean, since it depends on having a UserService (as expressed through the @Autowired annotation). You might want to have a look at an overview of the Spring container and/or the Spring MVC framework.

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

Sidebar

Related Questions

I have a ReSTful web service which needs to parse locale-sensitive data from the
I am trying to develop some RESTful web services which have to access some
I have a RESTful web service that returns JSON-serialized data. It can successfully serialize
I am new to Restful concept and have to design a simple API for
Consider following scenario: I have RESTful URL /articles that returns list of articles user
I have a restful web service which can deal with DTOs in json format
I have a restful webservice which receives some structured data which is put straight
I'm getting started on figuring out how to use RESTful design. I have this
I am building a web application with a services layer. The services layer is
I have Restful web-service implemented using Apache CXF. Since I am going to use

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.