Announcement Announcement Module
No announcement yet.
Configuration problem: Repositories Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Configuration problem: Repositories

    I am building a simple web application using:
    • Eclipse
    • Spring webmvc
    • Spring data
    • Hibernate

    So far I have successfully created a very simple webapp capable of presenting a list of things to do. The list is retrieved from a simple service and all is wired together using annotations.

    Now - I would like to have my simple service actually fetch the things to do from a database.

    Using Spring data I have been able to build entity, repository and configuration classes and I can use them to fetch data from the database and print it out to the console. But only when run stand-alone.

    As soon as my config class is visible to <context:component-scan> I get an error from my embedded TomCat:

    Configuration problem: RepositoriesRegistrar was @Import'ed but is not annotated with @Configuration nor does it declare any @Bean methods. Update the class to meet one of these requirements or do not attempt to @Import it.
    I have nailed the problem down to the @EnableJpaRepositories in the config class. The definition of this annotation includes @Import(value={JpaRepositoriesRegistrar.class}):

    package myproj.configs;
    import javax.persistence.EntityManagerFactory;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.context.annotation.Import;
    import org.springframework.orm.hibernate3.HibernateExceptionTranslator;
    import org.springframework.orm.jpa.JpaTransactionManager;
    import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
    import org.springframework.orm.jpa.vendor.HibernateJpaDialect;
    import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
    import org.springframework.transaction.annotation.EnableTransactionManagement;
    public class MyConfig {
        public EntityManagerFactory entityManagerFactory() {
            HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
            LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
            factory.setPackagesToScan(new String[] {"myproj"});
            return factory.getObject();
    I have been searching the web for similar problems for the last two days without success.

    Can anyone help?

    Please let me know if I need to supply additional information or source code.

    INFO: Initializing Spring FrameworkServlet 'MyWebApp'
    Jan 16, 2013 2:03:14 PM org.apache.catalina.core.ApplicationContext log
    SEVERE: StandardWrapper.Throwable
    org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: was @Import'ed but is not annotated with @Configuration nor does it declare any @Bean methods. Update the class to meet one of these requirements or do not attempt to @Import it.
    Offending resource: class path resource [org/springframework/data/jpa/repository/config/JpaRepositoriesRegistrar.class]
    	at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(
    	at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.doLoadBeanDefinitionForConfigurationClassIfNecessary(
    	at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(
    	at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(
    	at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(
    	at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigurationClasses(
    	at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(
    	at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(
    	at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(
    	at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(
    	at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(
    	at org.springframework.web.servlet.FrameworkServlet.initServletBean(
    	at org.springframework.web.servlet.HttpServletBean.init(
    	at javax.servlet.GenericServlet.init(
    	at org.apache.catalina.core.StandardWrapper.initServlet(
    	at org.apache.catalina.core.StandardWrapper.loadServlet(
    	at org.apache.catalina.core.StandardWrapper.load(
    	at org.apache.catalina.core.StandardContext.loadOnStartup(
    	at org.apache.catalina.core.StandardContext.startInternal(
    	at org.apache.catalina.util.LifecycleBase.start(
    	at org.apache.catalina.core.StandardContext.reload(
    	at org.apache.catalina.loader.WebappLoader.backgroundProcess(
    	at org.apache.catalina.core.ContainerBase.backgroundProcess(
    	at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(
    	at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(
    	at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(
    	at org.apache.catalina.core.ContainerBase$
    Last edited by Jenseman; Jan 16th, 2013, 02:28 PM.

  • #2
    How are you executing the code? Are you using a JUnit test? I just finished posting examples of this config here:

    Let me know if you are still stuck.

    Gordon Dickens


    • #3
      Hi Gordon,

      I do use JUnit but I havent implemented any tests yet.

      I dont really execute as such. The presence of the @EnableJpaRepositories immediatly breaks the automatic republishing of my servlet to Tomcat. The stackdump is from the Tomcat console output.

      I will revert when I have tried out your congiguration. Thanks:-)

      Best regards
      Jens Krogsboell


      • #4
        Hi Jens,

        I moved the repository to

        I will be adding to this the annotation config for a web app for the next commit.

        Sorry for the confusion.


        • #5
          Hi Gordon,

          Its no problem - I found it - it didn't solve my problem though.

          But yesterday afternoon a colleague of mine came to my rescue helping me sort out my dependencies. It turned out to be related to me trying to run spring-data 1.2.0 with spring-other-stuff 3.1.0.

          I have upgraded my project to spring 3.2.0.RELEASE and the problem has gone. Unfortunately I haven't been able to reproduce it afterwards, so I cant say exactly how it came about.

          But anyways - a YALVMI (Yet Another Library Version Mismatch Issue).

          Thanks a lot for you effort.