title: Integrating Spring Security with Vaadin 7
body: <p>I am new to vaadin 7. I am finding some problem with Spring Security Vaadin Integration. I am using JSP Login form to Login into my application. I am not able to log into my application, and I am unable to find the problem. </p>
  
  <p><strong>web.xml</strong></p>
  
  <pre><code>&lt;display-name&gt;Vaadin Web Application&lt;/display-name&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;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;
          /WEB-INF/applicationContext.xml
          /WEB-INF/applicationContext-security.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;listener&gt;
      &lt;listener-class&gt;com.vaadin.ui.application.spring.ApplicationContextListener&lt;/listener-class&gt;
  &lt;/listener&gt;
  
  &lt;servlet&gt;
      &lt;servlet-name&gt;TestApp&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.vaadin.ui.application.spring.SpringApplicationServlet&lt;/servlet-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;closeIdleSessions&lt;/param-name&gt;
          &lt;param-value&gt;true&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
          &lt;description&gt;Vaadin UIProvider class name&lt;/description&gt;
          &lt;param-name&gt;UIProvider&lt;/param-name&gt;
          &lt;param-value&gt;com.vaadin.ui.application.spring.ApplicationUIProvider&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
          &lt;description&gt;Vaadin application bean to start&lt;/description&gt;
          &lt;param-name&gt;UIBean&lt;/param-name&gt;
          &lt;param-value&gt;TestApplication&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;widgetset&lt;/param-name&gt;
          &lt;param-value&gt;com.vaadin.ui.application.AppWidgetSet&lt;/param-value&gt;
      &lt;/init-param&gt;
  &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;Test&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/home/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;Test&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/VAADIN/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;default&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/schema/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;loginform.jsp&lt;/welcome-file&gt;
  &lt;/welcome-file-list&gt;
  
  &lt;session-config&gt;
      &lt;session-timeout&gt;100&lt;/session-timeout&gt;
  &lt;/session-config&gt;
  </code></pre>
  
  <p><strong>SpringApplicationServlet.java</strong></p>
  
  <pre><code>    @Component
  public class SpringApplicationServlet extends VaadinServlet {
  
      private WebApplicationContext applicationContext;
      private Class&lt;? extends UI&gt; applicationClass;
      private String applicationBean;
      private LocaleResolver localeResolver;
  
      @SuppressWarnings("unchecked")
      @Override
      public void init(ServletConfig servletConfig) throws ServletException {
          super.init(servletConfig);
          applicationBean = servletConfig.getInitParameter("applicationBean");
          if (applicationBean == null) {
              throw new ServletException(
                      "ApplicationBean not specified in servlet parameters");
          }
          applicationContext = WebApplicationContextUtils
                  .getWebApplicationContext(servletConfig.getServletContext());
          applicationClass = (Class&lt;? extends UI&gt;) applicationContext
                  .getType(applicationBean);
          initLocaleResolver(applicationContext);
      }
  
      private void initLocaleResolver(ApplicationContext context) {
          try {
              this.localeResolver = (LocaleResolver) context.getBean(
                      DispatcherServlet.LOCALE_RESOLVER_BEAN_NAME,
                      LocaleResolver.class);
          } catch (NoSuchBeanDefinitionException ex) {
              this.localeResolver = new SessionLocaleResolver();
          }
      }
  
      protected void service(HttpServletRequest request,
              HttpServletResponse response) throws ServletException, IOException {
          final Locale locale = localeResolver.resolveLocale(request);
          LocaleContextHolder.setLocale(locale);
          ServletRequestAttributes requestAttributes = new ServletRequestAttributes(
                  request);
          RequestContextHolder.setRequestAttributes(requestAttributes);
          try {
              super.service(new HttpServletRequestWrapper(request) {
                  @Override
                  public Locale getLocale() {
                      return locale;
                  }
              }, response);
          } finally {
              if (!locale.equals(LocaleContextHolder.getLocale())) {
                  localeResolver.setLocale(request, response,
                          LocaleContextHolder.getLocale());
              }
              LocaleContextHolder.resetLocaleContext();
              RequestContextHolder.resetRequestAttributes();
          }
      }
  
      protected UI getNewApplication(HttpServletRequest request)
              throws ServletException {
          return (UI) applicationContext.getBean(applicationBean);
      }
  
      protected Class&lt;? extends UI&gt; getApplicationClass()
              throws ClassNotFoundException {
          return applicationClass;
      }
  </code></pre>
  
  <p>Please help me out with some sample code to get this working. </p>
  
  <p>Regards </p>
  
  <p>Abhilash</p>