Vaadin + Spring - refresh (F5): IllegalStateException: This UI instance is

Hello all,

I’m writing a Vaadin application and I’m using Spring 3.2.3, Spring Security 3.1.4 and Vaadin 7.2.3.

Page refresh (F5) causes exception:
HTTP Status 500 - com.vaadin.server.ServiceException: java.lang.IllegalStateException: This UI instance is already initialized (as UI id 0) and can therefore not be initialized again (as UI id 1). Please make sure you are not accidentally reusing an old UI instance.

Any tips?

web.xml[code]

 <filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>


[/code]
applicationContext.xml:

...
    <bean id="springSecurityFilterChain" class="org.springframework.security.web.FilterChainProxy">
        <constructor-arg>
            <list>
                <sec:filter-chain pattern="/**" filters="securityContextPersistenceFilterWithASCTrue"/>
            </list>
        </constructor-arg>
    </bean>
    <bean id="securityContextPersistenceFilterWithASCTrue"
          class="org.springframework.security.web.context.SecurityContextPersistenceFilter"/>
              
    <import resource="security.xml"/>
...

security.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans 
    xmlns="http://www.springframework.org/schema/security" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:beans="http://www.springframework.org/schema/beans"
    xsi:schemaLocation=
        "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
            http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">

    <!-- Enable the @Secured annotation to secure service layer methods -->
    <global-method-security secured-annotations="enabled" />

    <http auto-config="false" use-expressions="true">
        <intercept-url pattern="/**" access="permitAll" requires-channel="https"/>
        <form-login />
    </http>

    <authentication-manager>
        <authentication-provider ref="authenticateServiceImpl" />
    </authentication-manager>

</beans:beans>

MainUI.java

@Component
@Scope("session")

public class MainUI extends UI {
...

Hi,

You must change MainUI’s scope to “prototype”. “Session” scope hasn’t supported anymore.
https://github.com/xpoft/spring-vaadin#30