title: How to use the new Vaadin Spring Boot addon together with Vaadin4Spring EventBus
body: <p>The Vaadin team has currently released an addon which is as I understood based on the unofficial Vaadin4Spring addon:</p>
  
  <p>Vaadin Spring Boot:
  <a href="https://vaadin.com/directory#addon/vaadin-spring-boot" rel="nofollow">https://vaadin.com/directory#addon/vaadin-spring-boot</a></p>
  
  <p>Vaadin4Spring:
  <a href="https://github.com/peholmst/vaadin4spring" rel="nofollow">https://github.com/peholmst/vaadin4spring</a></p>
  
  <blockquote>
    <p>Please note! As of February 2015, Vaadin is working on an official
    Spring add-on which will be a small subset of Vaadin4Spring. Once the
    official add-on is released, Vaadin4Spring will be converted into a
    set of add-ons that provide features that the official add-on does not
    have. You can follow the progress of the official add-on here:
    <a href="https://github.com/vaadin/spring" rel="nofollow">https://github.com/vaadin/spring</a></p>
  </blockquote>
  
  <p>However, the Vaadin Spring Boot is missing some cool features which Vaadin4Spring has (like said above by Petter Holmström, the author of Vaadin4Spring), like the EventBus framework, which is really useful.</p>
  
  <p>Now I have set up a Maven project both with the Vaadin Spring Boot addon and the Vaadin4Spring addon:</p>
  
  <pre><code>    &lt;!-- Vaadin Spring Boot --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.vaadin&lt;/groupId&gt;
          &lt;artifactId&gt;vaadin-spring-boot&lt;/artifactId&gt;
          &lt;version&gt;${vaadin.spring.boot.version}&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>Basically, I would like to use the features of both the frameworks (or better, I would like to use <code>Vaadin Spring Boot</code> as the main framework and use the <code>Vaadin4Spring EventBus</code> features together with it). The problem I have noticed, however, is that it seems that both the frameworks cannot coexist with each other yet.</p>
  
  <p>If I add both the addons as above, when I run the application, no views and no UIs are found (below the log showing what I mean):</p>
  
  <pre><code>2015-03-01 22:07:22.001... SpringViewProvider: Looking up VaadinViews 
  2015-03-01 22:07:22.006  WARN SpringViewProvider: No VaadinViews found ... 
  ...
  2015-03-01 22:12:12.584  INFO: Checking the application context for Vaadin UIs 
  2015-03-01 22:12:12.594  WARN: Found no Vaadin UIs in the application context
  </code></pre>
  
  <p>But the Views and the UI do exist! They are managed by the <code>Vaadin Spring Boot</code> addon (here is some sample code):</p>
  
  <p>UI:</p>
  
  <pre><code>@SpringUI("")
  @Theme("valo")
  public class DemoUI extends UI {
  
      private static final long serialVersionUID = 193481619798227053L;
  
      @Autowired
      private Greeter greeter;
  
      @Autowired
      private ApplicationContext applicationContext;
  
      private final SpringViewProvider viewProvider;
  
      private VerticalLayout layout;
  
      @Autowired
      public DemoUI(SpringViewProvider viewProvider) {
          this.viewProvider = viewProvider;
      }
  
      @Override
      protected void init(VaadinRequest request) {        
          layout = new VerticalLayout();
          layout.setMargin(true);
          layout.setSpacing(true);
          setContent(layout);
  
          Label greetings = new Label(greeter.getGreeting());
          layout.addComponent(greetings);
  
          final CssLayout navigationBar = new CssLayout();
          navigationBar.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
          navigationBar.addComponent(createNavigationButton("View Scoped View", ViewScopedView.VIEW_NAME));
          navigationBar.addComponent(createNavigationButton("UI Scoped View", UIScopedView.VIEW_NAME));
          navigationBar.addComponent(createNavigationButton("Another UI Scoped View", AnotherUIScopedView.VIEW_NAME));
          layout.addComponent(navigationBar);     
  
          final Panel viewContainer = new Panel();
          viewContainer.setSizeFull();
          layout.addComponent(viewContainer);
          layout.setExpandRatio(viewContainer, 1.0f);
  
          Navigator navigator = new Navigator(this, viewContainer);
          navigator.addProvider(viewProvider);
  
  
  
      }
  
      private Button createNavigationButton(String caption, String viewName) {
          Button button = new Button(caption);
          button.addStyleName(ValoTheme.BUTTON_SMALL);
          button.addClickListener(event -&gt; { 
              try {
                  getUI().getNavigator().navigateTo(viewName);
              }
              catch (IllegalArgumentException e) {
                  // view with the given name is not mapped
                  System.out.println("Not mapped view with name: " + viewName);
              }
          });
          return button;
      }
  
  }
  </code></pre>
  
  <p>A view annotated with @SpringView:</p>
  
  <pre><code>@SpringView(DefaultView.VIEW_NAME)
  public class DefaultView extends VerticalLayout implements View {
  
      private static final long serialVersionUID = -2052937117362922764L;
  
      public static final String VIEW_NAME = "";
  
      @Override
      public void enter(ViewChangeEvent event) {
           // the view is constructed in the init() method()      
      }
  
      @PostConstruct
      void init() {
          addComponent(new Label("This is the default view"));
      }
  
  }
  </code></pre>
  
  <p>The same goes for other views. And everything works, when these two dependencies are removed from the pom.xml:</p>
  
  <pre><code>    &lt;!-- Vaadin4Spring addon, the EventBus framework needs this addon --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.vaadin.spring&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-vaadin&lt;/artifactId&gt;
          &lt;version&gt;0.0.5-SNAPSHOT&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;!-- Vaadin4Spring EventBus feature I would like to use with Vaadin Spring Boot --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.vaadin.spring&lt;/groupId&gt;
          &lt;artifactId&gt;spring-vaadin-eventbus&lt;/artifactId&gt;
          &lt;version&gt;0.0.5-SNAPSHOT&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>Not allowing me to use the EventBus framework. Did anyone already explore the new addon too and had the same need? Did you find out how to integrate the two worlds? Or is it still early to use Vaadin4Spring tools into Vaadin Spring Boot and we should wait that the Vaadin4Spring features get converted into a set of addons which will complete <code>Vaadin Spring Boot</code> as is said in the first block I posted?</p>
  
  <p>EDIT: I also tried to add a <code>@ComponentScan</code> annotation to the Spring Boot application class while having the three dependencies together, didn't help...</p>
  
  <p>If I add <code>spring-vaadin</code> instead of <code>spring-boot-vaadin</code>:</p>
  
  <pre><code>        &lt;!-- Vaadin4Spring --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.vaadin.spring&lt;/groupId&gt;
              &lt;artifactId&gt;spring-vaadin&lt;/artifactId&gt;
              &lt;version&gt;${vaadin4spring.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- Vaadin4Spring EventBus framework --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.vaadin.spring&lt;/groupId&gt;
              &lt;artifactId&gt;spring-vaadin-eventbus&lt;/artifactId&gt;
              &lt;version&gt;${vaadin4spring.version}&lt;/version&gt;
          &lt;/dependency&gt;
  </code></pre>
  
  <p>Views and UIs are loaded and I can see them in the browser, but as soon as I want to start using an event bus, I get the following exception:</p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'vaadinSpringBootDemoApplication': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.vaadin.spring.events.EventBus$ApplicationEventBus demo.VaadinSpringBootDemoApplication.applicationEventBus; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.vaadin.spring.events.EventBus$ApplicationEventBus] 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)}
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1202)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:762)
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
      at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
      at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:961)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:950)
      at demo.VaadinSpringBootDemoApplication.main(VaadinSpringBootDemoApplication.java:21)
  Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.vaadin.spring.events.EventBus$ApplicationEventBus demo.VaadinSpringBootDemoApplication.applicationEventBus; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.vaadin.spring.events.EventBus$ApplicationEventBus] 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)}
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:561)
      at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
      ... 16 common frames omitted
  Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.vaadin.spring.events.EventBus$ApplicationEventBus] 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)}
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1308)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1054)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:949)
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:533)
      ... 18 common frames omitted
  </code></pre>
  
  <p>It seems that the EventBus.* beans don't get registered inside the Spring IoC container. What to do?</p>