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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:03:40+00:00 2026-05-26T08:03:40+00:00

I keep getting a NoSuchBeanDefinitionException in my service layer and I have no idea

  • 0

I keep getting a NoSuchBeanDefinitionException in my service layer and I have no idea why, any help will be appreciated. This is out of spring in action book, the spitter app. Am i missing something. I am trying to build it myself using maven instead of gradle.

Exception:

org.springframework.beans.factory.BeanCreationException: Error creating bean witlerMapping#0': Initialization of bean failed; 
nested exception is org.springfram name 'homeController' defined in file [/data/TOMCAT-6.0/apache-tomcat-6.0.33/wess]: Unsatisfied dependency expressed through constructor argument with index 0  of type [com.john.springinaction.service.SpitterService] found for dependency: ndency. Dependency annotations: {}; 
nested exception is org.springframework.beanspringinaction.service.SpitterService] found for dependency: expected at least 1annotations: {}

    at org.springframework.beans.factory.support.AbstractAutowireCapableBean
    at org.springframework.beans.factory.support.AbstractAutowireCapableBean
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.
    at org.springframework.context.support.AbstractApplicationContext.finish
    at org.springframework.context.support.AbstractApplicationContext.refres
    at org.springframework.web.servlet.FrameworkServlet.createWebApplication
    at org.springframework.web.servlet.FrameworkServlet.createWebApplication
    at org.springframework.web.servlet.FrameworkServlet.initWebApplicationCo
    at org.springframework.web.servlet.FrameworkServlet.initServletBean(Fram
    at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.
    at javax.servlet.GenericServlet.init(GenericServlet.java:212)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.
    at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.jav
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:48
    at java.lang.Thread.run(Thread.java:619)

Controller:

package com.john.springinaction.mvc;

import java.util.Map;

import javax.inject.Inject;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.john.springinaction.service.SpitterService;

@Controller
public class HomeController {

    public static final int DEFAULT_SPITTLES_PER_PAGE = 25;

    @Autowired
    private SpitterService spitterService;


    @RequestMapping({"/","/home"})
    public String showHomePage(Map<String, Object> model) {
        model.put("spittles", 
            spitterService.getRecentSpittles(DEFAULT_SPITTLES_PER_PAGE));
        return "home";
    }
}

Service:

package com.john.springinaction.service;

import static java.lang.Math.min;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.john.springinaction.domain.Spitter;
import com.john.springinaction.domain.Spittle;
import com.john.springinaction.persistence.SpitterDAO;

@Service("spitterService")
@Transactional(propagation = Propagation.REQUIRED)
public class SpitterServiceImpl implements SpitterService {

    @Autowired
    private SpitterDAO spitterDAO;

    @Transactional(propagation=Propagation.SUPPORTS, readOnly=true)
    public List<Spittle> getRecentSpittles(int count) {
        List<Spittle> recentSpittles =
            spitterDAO.getRecentSpittle();
        return recentSpittles.subList(0, min(49, recentSpittles.size()));
    }

    public void saveSpittle(Spittle spittle) {
        spittle.setWhen(new Date());
        spitterDAO.saveSpittle(spittle);

    }

    @Transactional(propagation=Propagation.SUPPORTS, readOnly=false)
    public void saveSpitter(Spitter spitter) {
        if (spitter.getId() == null) {
            spitterDAO.addSpitter(spitter);
        }else {         
            spitterDAO.saveSpitter(spitter);
        }
    }

    @Transactional(propagation=Propagation.SUPPORTS, readOnly=false)
    public void deleteSpitter(Spitter spitter) {
        spitterDAO.deleteSpitter(spitter);

    }

    @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
    public Spitter getSpitter(long id) {
        return spitterDAO.getSpitterById(id);
    }

    public void startFollowing(Spitter follower, Spitter followee) {

    }

    public List<Spittle> getSpittlesForSpitter(Spitter spitter) {
         return spitterDAO.getSpittlesForSpitter(spitter);
    }

    public List<Spittle> getSpittlesForSpitter(String username) {
        return spitterDAO.getSpittlesForSpitter(username);
    }

    public Spitter getSpitter(String username) {
        return spitterDAO.getSpitterByUsername(username);
    }

    public Spittle getSpittleById(long id) {
        return spitterDAO.getSpittleById(id);
    }

    public void deleteSpittle(long id) {
        spitterDAO.deleteSpittle(id);

    }

    public List<Spitter> getAllSpitters() {
        return null;
    }


}

beanlocations.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context.xsd
    http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd">

    <!-- Database Configuration -->
    <import resource="DataSource.xml"/>
    <import resource="Hibernate.xml"/>
    <import resource="Service.xml"/>

    <!-- Auto scan the components -->
    <context:component-scan base-package="com.john.springinaction" />
    <context:annotation-config/>
</beans>

hibernate.xml

 <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.0.xsd">

    <context:component-scan base-package="com.john.springinaction.service" />

    <tx:annotation-driven/>
</beans>

web.xml

 <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" 
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
         version="2.4" 
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
                   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

    <!-- context load listener -->
    <listener>
        <listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>

    <!-- <listener>
        <listener-class>org.apache.tiles.web.startup.TilesListener</listener-class>
    </listener> -->

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            classpath:*BeanLocations.xml
        </param-value>
    </context-param>
    <servlet>
        <servlet-name>spitter</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>spitter</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

</web-app>

pom.xml

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

  <modelVersion>4.0.0</modelVersion>
  <groupId>com.john.springinaction</groupId>
  <artifactId>Spitter</artifactId>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>Spitter</name>
  <url>http://maven.apache.org</url>

  <repositories>
    <repository>
      <id>JBoss repository</id>
      <url>http://repository.jboss.com/maven2/</url>
    </repository>
  </repositories>

  <properties>
    <spring.version>3.0.5.RELEASE</spring.version>
  </properties>
  <dependencies>

  <!-- Test Dependencies -->
    <dependency>  
        <groupId>junit</groupId>  
        <artifactId>junit</artifactId>  
        <version>4.7</version>  
        <scope>test</scope>  
    </dependency>  

    <!-- Spring framework -->
    <!-- <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring</artifactId>
        <version>2.5.6</version>
    </dependency> -->

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>3.0.6.RELEASE</version>
    </dependency>

    <!-- Spring AOP Dependency -->
    <dependency>
        <groupId>cglib</groupId>
        <artifactId>cglib</artifactId>
        <version>2.2</version>
    </dependency>

    <!-- Spring MVC framework -->

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${spring.version}</version>
    </dependency>


    <!-- MySQL database driver -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.9</version>
    </dependency>

    <!-- Hibernate framework -->
     <dependency>
       <groupId>org.hibernate</groupId>
       <artifactId>hibernate-core</artifactId>
       <version>3.3.2.GA</version>
    </dependency>

    <!-- Hibernate annotation -->
    <dependency>
       <groupId>org.hibernate</groupId>
       <artifactId>hibernate-annotations</artifactId>
       <version>3.4.0.GA</version>
    </dependency>
    <dependency>
       <groupId>org.hibernate</groupId>
       <artifactId>hibernate-commons-annotations</artifactId>
       <version>3.3.0.ga</version>
    </dependency>

    <!-- Hibernate library dependecy start -->
    <dependency>
        <groupId>dom4j</groupId>
        <artifactId>dom4j</artifactId>
        <version>1.6.1</version>
    </dependency>

    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.1.1</version>
    </dependency>

    <dependency>
        <groupId>commons-collections</groupId>
        <artifactId>commons-collections</artifactId>
        <version>3.2.1</version>
    </dependency>

    <dependency>
        <groupId>antlr</groupId>
        <artifactId>antlr</artifactId>
        <version>2.7.7</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.5.6</version>
    </dependency>

    <dependency>
        <groupId>javassist</groupId>
        <artifactId>javassist</artifactId>
        <version>3.12.1.GA</version>
    </dependency>
    <!-- Hibernate library dependecy end -->

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>3.0.6.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>2.3</version>
    </dependency>

    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>1.0.0.GA</version>
    </dependency>

    <dependency>
        <groupId>com.sun.jersey.glassfish.v3.osgi</groupId>
        <artifactId>jackson-core-asl</artifactId>
        <version>1.1.5</version>
    </dependency>

    <dependency>  
        <groupId>javax.inject</groupId>  
        <artifactId>javax.inject</artifactId>  
        <version>1</version>  
    </dependency>

  </dependencies>

  <build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.5</source>
                <target>1.5</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1.1</version>
            <configuration>
                <outputDirectory>target/artefacts/wars</outputDirectory>
                <warName>spitter</warName>
            </configuration>
        </plugin>
    </plugins>
  </build>
</project>
  • 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-26T08:03:43+00:00Added an answer on May 26, 2026 at 8:03 am

    It seems that you might have SpitterService in different packages. Try to specify which one you want exactly in the controller by either:

    @Autowired
    @Qualifier( "spitterService" )
    private SpitterService spitterService;
    

    or

    @Resource( name="spitterService" )
    private SpitterService spitterService;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Keep getting an error when I run the following. Any help greatly appreciated. John
I keep getting this error while setting up ehcache in Spring MVC. org.springframework.beans.factory.BeanCreationException: Error
I keep getting this error: alt text http://img514.imageshack.us/img514/2203/help.tif What is it? I never even
Keep getting this error after inserting a subdatasheet into a query and trying to
I keep getting tasks that are above my skill level. How can I address this without coming accross as grossly incompetent?
I keep getting this NPE in my application and I can't seem to get
I keep getting this : DeprecationWarning: integer argument expected, got float How do I
I keep getting this error when I try to build my solution. I've tried
I keep getting... org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: You cannot use a spring-security-2.0.xsd schema with Spring
I keep getting this whenever I run the below code: Fatal error: Call 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.