I have a following start for my Vaadin + Spring project.
The main UI class:
@SpringUI
@Theme("person")
public class PersonUI extends UI {
@Autowired
SpringViewProvider viewProvider;
@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(productionMode = true, ui = PersonUI.class, heartbeatInterval = 60, resourceCacheTime = 3600, closeIdleSessions = true)
public static class Servlet extends SpringVaadinServlet {
}
@WebListener
public static class PersonContextLoaderListener extends ContextLoaderListener {
}
@Configuration
@EnableVaadin
public static class PersonConfiguration {
}
@Override
protected void init(VaadinRequest request) {
VerticalLayout rootLayout = new VerticalLayout();
HeaderLayout headerLayout = new HeaderLayout();
rootLayout.addComponents(headerLayout, contentContainer);
Navigator navigatorLocal = new Navigator(this, contentContainer);
navigatorLocal.addProvider(viewProvider);
navigatorLocal.addView("", LoginView.class);
navigatorLocal.addView(PersonListView.NAME, PersonListView.class);
setNavigator(navigatorLocal);
}
and
WEB-INF/applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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/context
http://www.springframework.org/schema/context/spring-context-4.1.xsd">
<bean class="com.mycompany.PersonUI.PersonConfiguration" />
<context:component-scan base-package="com.mycompany" />
</beans>
and
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>person</artifactId>
<packaging>war</packaging>
<version>1.0.0</version>
<properties>
<applicationContextName>person</applicationContextName>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<vaadin.version>7.6.6</vaadin.version>
</properties>
<repositories>
<repository>
<id>vaadin-addons</id>
<url>http://maven.vaadin.com/vaadin-addons</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.2.6.RELEASE</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-server</artifactId>
<version>${vaadin.version}</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client-compiled</artifactId>
<version>${vaadin.version}</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-themes</artifactId>
<version>${vaadin.version}</version>
</dependency>
...
</dependencies>
</build>
...
</build>
</project>
I have no
web.xml
file.
And the exception is when requesting
http://localhost:8080/person/
com.vaadin.server.DefaultErrorHandler doDefault
SEVERE:
java.lang.IllegalStateException: [com.mycompany.PersonUI]
is already mapped to the path
at com.vaadin.spring.server.SpringUIProvider.detectUIs(SpringUIProvider.java:83)
and
WARN:oejs.ServletHandler:qtp1991615833-36:
javax.servlet.ServletException: com.vaadin.server.ServiceException: com.vaadin.server.ServiceException: No UIProvider has been added and there is no "UI" init parameter.
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:366)
Vaadin Spring related documentation is not very good, so does anyone have an idea what is the problem?