title: Spring integration with Vaadin doesn't work
body: <p>I'm trying to integrate Spring Dependency Injection with my Vaadin <code>application/servlet</code>. However the dependency injection doesn't work. I think Spring reads the components fine:</p>
  
  <pre><code>2013-01-15 06:57:11,361 [localhost-startStop-1] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [com/nortal/pirs/spring/application-context.xml]
  2013-01-15 06:57:12,012 [localhost-startStop-1] INFO  org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@fa5214b: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,org.springframework.context.config.internalBeanConfigurerAspect,mainController,UserManager,VisitManager,mainWindow,org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor#0,org.springframework.context.annotation.CommonAnnotationBeanPostProcessor#0,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; root of factory hierarchy
  </code></pre>
  
  <p>Since I can see my required objects like <code>UserManager</code>, <code>mainWindow</code>...</p>
  
  <p>However when it comes to actual injection, it doesn't seem to work. I get nullpointerexceptions with it.</p>
  
  <p>Right now I'm trying to test it with <code>MainWindow</code>, here's the application that should get <code>MainWindow</code> injected:</p>
  
  <pre><code>    @Configurable
  public class PirsVaadinController extends Application implements
          NavigatorInterface {
  
      private String title = "WELCOME";
      private transient Logger log;
      private Map userData;
      private boolean useFakeData = false;
  
      @Autowired
      private MainWindow mainWindow;
  
  public UserManagerInterface getUserManager() {
          return userManager;
      }
  
      @Autowired
      public void setUserManager(UserManagerInterface userManager) {
          this.userManager = userManager;
      }
  </code></pre>
  
  <p>Yes I know I put <code>@Autowired</code> on both: the setter and the variable itself, however it doesn't work either way.</p>
  
  <p><strong>MainWindow:</strong></p>
  
  <pre><code> @org.springframework.stereotype.Component
  @org.springframework.context.annotation.Scope("session")
  public class MainWindow extends Window {
  </code></pre>
  
  <p><strong>My web.xml:</strong></p>
  
  <pre><code>&lt;!-- Vaadin --&gt;
  
  &lt;context-param&gt;
      &lt;description&gt;Vaadin production mode&lt;/description&gt;
      &lt;param-name&gt;productionMode&lt;/param-name&gt;
      &lt;param-value&gt;true&lt;/param-value&gt;
  &lt;/context-param&gt;
  
  &lt;servlet&gt;
      &lt;servlet-name&gt;PirsVaadinFrontend&lt;/servlet-name&gt;
      &lt;servlet-class&gt;
          com.vaadin.terminal.gwt.server.ApplicationServlet
      &lt;/servlet-class&gt;
      &lt;init-param&gt;
          &lt;description&gt;Vaadin application class to start&lt;/description&gt;
          &lt;param-name&gt;application&lt;/param-name&gt;
          &lt;param-value&gt;
              com.nortal.pirs.presentation.vaadin.PirsVaadinController
          &lt;/param-value&gt;
      &lt;/init-param&gt;
  &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;PirsVaadinFrontend&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;!-- Spring --&gt;
  
  &lt;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;classpath:com\nortal\pirs\spring\application-context.xml&lt;/param-value&gt;
  &lt;/context-param&gt;
  
  &lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
  &lt;/listener&gt;
  
  &lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.context.request.RequestContextListener&lt;/listener-class&gt;
  &lt;/listener&gt;
  
  &lt;!-- EmailCheck REST web service --&gt;
  
  &lt;servlet&gt;
      &lt;servlet-name&gt;emailCheckService&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.sun.jersey.spi.container.servlet.ServletContainer&lt;/servlet-class&gt;
  
      &lt;init-param&gt;
          &lt;param-name&gt;com.sun.jersey.config.property.packages&lt;/param-name&gt;
          &lt;param-value&gt;com.nortal.pirs.webservices&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;emailCheckService&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/webservices/*&lt;/url-pattern&gt;
  
  &lt;/servlet-mapping&gt;
  
  &lt;!-- General parameters --&gt;
  
  &lt;session-config&gt;
      &lt;session-timeout&gt;60&lt;/session-timeout&gt;
  &lt;/session-config&gt;
  </code></pre>
  
  <p>My Spring application-context:</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
      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/aop 
          http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
          http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-3.1.xsd"&gt;
  
      &lt;context:annotation-config /&gt;
  
      &lt;!-- Turn on AspectJ @Configurable support --&gt;
      &lt;context:spring-configured /&gt;
  
      &lt;context:component-scan base-package="com.nortal.pirs.test.independent" /&gt;
      &lt;context:component-scan base-package="com.nortal.pirs.businesslogic.logic" /&gt;
      &lt;context:component-scan base-package="com.nortal.pirs.presentation.vaadin" /&gt;
  
      &lt;!-- Turn on @Autowired, @PostConstruct etc support --&gt;
      &lt;bean
          class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor" /&gt;
      &lt;bean
          class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor" /&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p><strong>My Maven pom.xml:</strong></p>
  
  <pre><code>&lt;repositories&gt;
      &lt;repository&gt;
          &lt;id&gt;com.springsource.repository.bundles.release&lt;/id&gt;
          &lt;name&gt;EBR Spring Release Repository&lt;/name&gt;
          &lt;url&gt;http:// repository.springsource.com/maven/bundles/release&lt;/url&gt;
      &lt;/repository&gt;
      &lt;repository&gt;
          &lt;id&gt;com.springsource.repository.bundles.external&lt;/id&gt;
          &lt;name&gt;EBR External Release Repository&lt;/name&gt;
          &lt;url&gt;http:// repository.springsource.com/maven/bundles/external&lt;/url&gt;
      &lt;/repository&gt;
  &lt;/repositories&gt;
  
  &lt;build&gt;
      &lt;sourceDirectory&gt;src/&lt;/sourceDirectory&gt;
      &lt;directory&gt;${basedir}/build&lt;/directory&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.1&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;source&gt;1.6&lt;/source&gt;
                  &lt;target&gt;1.6&lt;/target&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
  
          &lt;!-- Additional --&gt;
  
          &lt;plugin&gt;
              &lt;groupId&gt;org.eclipse.m2e&lt;/groupId&gt;
              &lt;artifactId&gt;lifecycle-mapping&lt;/artifactId&gt;
              &lt;version&gt;1.0.0&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;lifecycleMappingMetadata&gt;
                      &lt;pluginExecutions&gt;
                          &lt;pluginExecution&gt;
                              &lt;pluginExecutionFilter&gt;
                                  &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
                                  &lt;artifactId&gt;aspectj-maven-plugin&lt;/artifactId&gt;
                                  &lt;versionRange&gt;1.2&lt;/versionRange&gt;
                                  &lt;goals&gt;
                                      &lt;goal&gt;test-compile&lt;/goal&gt;
                                      &lt;goal&gt;compile&lt;/goal&gt;
                                  &lt;/goals&gt;
                              &lt;/pluginExecutionFilter&gt;
                              &lt;action&gt;
                                  &lt;execute /&gt;
                              &lt;/action&gt;
                          &lt;/pluginExecution&gt;
                      &lt;/pluginExecutions&gt;
                  &lt;/lifecycleMappingMetadata&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
  
          &lt;!-- Vaadin - Spring --&gt;
  
          &lt;plugin&gt;
              &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
              &lt;artifactId&gt;aspectj-maven-plugin&lt;/artifactId&gt;
              &lt;version&gt;1.2&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;!-- Required as the plugin does not resolve this by default --&gt;
                  &lt;source&gt;${maven.compiler.source}&lt;/source&gt;
                  &lt;target&gt;${maven.compiler.target}&lt;/target&gt;
                  &lt;aspectLibraries&gt;
                      &lt;aspectLibrary&gt;
                          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
                          &lt;artifactId&gt;spring-aspects&lt;/artifactId&gt;
                      &lt;/aspectLibrary&gt;
                  &lt;/aspectLibraries&gt;
              &lt;/configuration&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;compile&lt;/goal&gt;
                          &lt;goal&gt;test-compile&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
  
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p>I didn't supply the dependencies, because I'd probably hit the character limit, however the dependencies don't seem to be lacking imho. in pom.xml I do get this error:</p>
  
  <pre><code>Multiple annotations found at this line:
  - Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:aspectj-maven-plugin:1.2:test-compile (execution: default, phase: 
   process-test-sources)
  - Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:aspectj-maven-plugin:1.2:compile (execution: default, phase: process-
   sources)
  </code></pre>
  
  <p>But from command line everything seems to be compiling well:</p>
  
  <pre><code> mvn compile
  [INFO] Scanning for projects...
  [INFO]
  [INFO] ------------------------------------------------------------------------
  [INFO] Building PIRS AMS 1.0
  [INFO] ------------------------------------------------------------------------
  [INFO]
  [INFO] --- aspectj-maven-plugin:1.2:compile (default) @ PIRS_AMS_WEB ---
  [INFO]
  [INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ PIRS_AMS_W
  EB ---
  [debug] execute contextualize
  [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
  i.e. build is platform dependent!
  [INFO] skip non existing resourceDirectory D:\Dropbox\EclipseWorkspace\PIRS_FIX\src\main\resources
  [INFO]
  [INFO] --- maven-compiler-plugin:2.1:compile (default-compile) @ PIRS_AMS_WEB --
  -
  [WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. b
  uild is platform dependent!
  [INFO] Compiling 1 source file to D:\Dropbox\EclipseWorkspace\PIRS_FIX\build\classes
  [INFO] ------------------------------------------------------------------------
  [INFO] BUILD SUCCESS
  [INFO] ------------------------------------------------------------------------
  [INFO] Total time: 2.617s
  [INFO] Finished at: Tue Jan 15 07:35:39 EET 2013
  [INFO] Final Memory: 16M/309M
  [INFO] ------------------------------------------------------------------------
  </code></pre>
  
  <p>As I said, everything works up to the point, where it actually needs to be injected, no error messages before <code>nullpointerexception</code>. </p>
  
  <p>Anyone knows what's wrong? </p>
  
  <p>Thanks.</p>