Spring load only one bean from all configurations

In the debugger I see beans that not related to Apache CFX or Hibernateare are loaded, but these two types of beans are not, and doesn’t matter in which configuration file they’re defined. Exceptions that it throws tells only that beans are not initialized, but I don’t see any information about why has this happened.
When I run them vie SpringRunner for unit tests – everything fine.

I have two guesses:
1. Something wrong in servlet initialization, but I didn’t found any mistakes there.
2. It happens because for project deploying and running I use Smart Tomcat plugin for Intellij Idea (I can use only Community Edition)

That’s how I initialize the app:

public class WebServiceDispatcherServletInitializer implements WebApplicationInitializer {

    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {
        AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
        context.register(WebServiceConfig.class, RootConfig.class, PersistenceConfig.class);
        servletContext.addListener(new ContextLoaderListener(context));


        ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", new CXFServlet());
        dispatcher.setLoadOnStartup(1);
        dispatcher.addMapping("/services/*");
    }
}

How to fix this and run the application correctly?

Leave a Reply

avatar
  Subscribe  
Notify of