I am trying to build a (war) project with Vaadin (23) + Spring boot (2.7+) on Payara (5.2), after a lot of configurations it finally started but the initial UI is loaded 3 times.
This is the log from the server:
INFO: 13:28:38.744 [admin-thread-pool::admin-listener(2)] INFO org.springframework.data.jpa.repository.cdi.JpaRepositoryExtension - Activating CDI extension for Spring Data JPA repositories.
INFO: WELD-000411: Observer method [BackedAnnotatedMethod] protected org.springframework.data.repository.cdi.CdiRepositoryExtensionSupport.processAnnotatedType(@Observes ProcessAnnotatedType<X>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
INFO: Clustered CDI Event bus initialized
INFO: Registering WebSocket filter for url pattern /*
INFO: WebModule[/skeleton-starter-flow-23] ServletContext.log():Initializing AtmosphereFramework
INFO: Initializing Soteria 1.1-b01.payara-p5 for context '/skeleton-starter-flow-23'
INFO: 13:28:39.682 [admin-thread-pool::admin-listener(2)] DEBUG com.vaadin.base.devserver.stats.DevModeUsageStatistics - Telemetry enabled
INFO: 13:28:39.695 [admin-thread-pool::admin-listener(2)] DEBUG com.vaadin.base.devserver.stats.StatisticsStorage - Reading statistics from C:\Users\FiruzzZ\.vaadin\usage-statistics.json
INFO: 13:28:39.718 [admin-thread-pool::admin-listener(2)] DEBUG com.vaadin.base.devserver.stats.StatisticsStorage - Reading statistics from C:\Users\FiruzzZ\.vaadin\usage-statistics.json
INFO: 13:28:39.735 [admin-thread-pool::admin-listener(2)] INFO com.vaadin.base.devserver.startup.DevModeStartupListener - Starting dev-mode updaters in C:\NetBeansProjects\skeleton-starter-flow-23 folder.
INFO: 13:28:39.783 [admin-thread-pool::admin-listener(2)] DEBUG com.vaadin.flow.server.frontend.scanner.FullDependenciesScanner -
List of npm dependencies found in the project:
- @polymer/iron-icon 3.0.1 com.vaadin.flow.component.icon.IronIcon
- @polymer/iron-list 3.1.0 com.vaadin.flow.component.ironlist.IronList
INFO: 13:28:39.789 [admin-thread-pool::admin-listener(2)] DEBUG com.vaadin.flow.server.frontend.scanner.FullDependenciesScanner -
List of @JavaScript found in the project:
INFO: 13:28:39.796 [admin-thread-pool::admin-listener(2)] INFO com.vaadin.flow.server.frontend.scanner.FullDependenciesScanner - Visited 80 classes. Took 26 ms.
INFO: 13:28:39.835 [admin-thread-pool::admin-listener(2)] DEBUG com.vaadin.flow.server.startup.VaadinAppShellInitializer - Using com.camioneros.AppShell class for configuring `index.html` response
INFO: 13:28:39.842 [ForkJoinPool.commonPool-worker-9] DEBUG com.vaadin.flow.server.frontend.TaskGeneratePackageJson - writing file C:\NetBeansProjects\skeleton-starter-flow-23\target\flow-frontend\package.json.
INFO: WebModule[/skeleton-starter-flow-23] ServletContext.log():2 Spring WebApplicationInitializers detected on classpath
INFO: onStartup: org.apache.catalina.core.ApplicationContextFacade@7aa203df
Here is an idea about displaying the Spring WebpAppInit detected on classpath, but it just shows one. Took it from here
@Theme("my-theme")
@SpringBootApplication
public class AppShell extends SpringBootServletInitializer implements AppShellConfigurator {
public static void main(String[] args) {
SpringApplication.run(AppShell.class, args);
}
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
System.out.println("onStartup: " + servletContext);
super.onStartup(servletContext);
}
}
and finally this is the POM
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.camioneros</groupId>
<artifactId>ddjj</artifactId>
<name>sas-ddjj</name>
<version>1.0</version>
<packaging>war</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<failOnMissingWebXml>false</failOnMissingWebXml>
<vaadin.version>23.2.10</vaadin.version>
<drivers.downloader.phase>pre-integration-test</drivers.downloader.phase>
<!-- this parameter is needed as spring-boot bom overwrites it -->
<selenium.version>4.5.3</selenium.version>
<maven.compiler.release>11</maven.compiler.release>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.6</version>
</parent>
<repositories>
<!-- The order of definitions matters. Explicitly defining central here to make sure it has the highest priority. -->
<repository>
<id>central</id>
<url>https://repo.maven.apache.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>vaadin-prereleases</id>
<url>
https://maven.vaadin.com/vaadin-prereleases/
</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<!-- Repository used by many Vaadin add-ons -->
<repository>
<id>Vaadin Directory</id>
<url>https://maven.vaadin.com/vaadin-addons</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<!-- The order of definitions matters. Explicitly defining central here to make sure it has the highest priority. -->
<pluginRepository>
<id>central</id>
<url>https://repo.maven.apache.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>vaadin-prereleases</id>
<url>
https://maven.vaadin.com/vaadin-prereleases/
</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-bom</artifactId>
<type>pom</type>
<scope>import</scope>
<version>${vaadin.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<!-- Replace artifactId with vaadin-core to use only free components -->
<artifactId>vaadin-core</artifactId>
</dependency>
<!-- Added to provide logging output as Vaadin uses -->
<!-- the unbound SLF4J no-operation (NOP) logger implementation -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</dependency>
<!-- <dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
</dependency>-->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-testbench</artifactId>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager -->
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>5.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hotswapagent</groupId>
<artifactId>hotswap-agent</artifactId>
<version>1.4.1</version>
<scope>runtime</scope>
<exclusions>
<exclusion>
<groupId>org.hotswapagent</groupId>
<artifactId>hotswap-agent-hibernate3-plugin</artifactId>
</exclusion>
<exclusion>
<groupId>org.hotswapagent</groupId>
<artifactId>hotswap-agent-deltaspike-plugin</artifactId>
</exclusion>
<exclusion>
<groupId>org.hotswapagent</groupId>
<artifactId>hotswap-agent-mybatis-plugin</artifactId>
</exclusion>
<exclusion>
<groupId>org.hotswapagent</groupId>
<artifactId>hotswap-agent-myfaces-plugin</artifactId>
</exclusion>
<exclusion>
<groupId>org.hotswapagent</groupId>
<artifactId>hotswap-agent-wildfly-el-plugin</artifactId>
</exclusion>
<exclusion>
<groupId>org.hotswapagent</groupId>
<artifactId>hotswap-agent-zk-plugin</artifactId>
</exclusion>
<exclusion>
<groupId>org.hotswapagent</groupId>
<artifactId>hotswap-agent-weld-plugin</artifactId>
</exclusion>
<exclusion>
<groupId>org.hotswapagent</groupId>
<artifactId>hotswap-agent-tomcat-plugin</artifactId>
</exclusion>
<exclusion>
<groupId>org.hotswapagent</groupId>
<artifactId>hotswap-agent-jbossmodules-plugin</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<artifactId>tomcat-embed-logging-juli</artifactId>
<groupId>org.apache.tomcat.embed</groupId>
</exclusion>
<exclusion>
<artifactId>tomcat-embed-websocket</artifactId>
<groupId>org.apache.tomcat.embed</groupId>
</exclusion>
<exclusion>
<artifactId>tomcat-embed-el</artifactId>
<groupId>org.apache.tomcat.embed</groupId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-el</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<!--<defaultGoal>jetty:run</defaultGoal>-->
<plugins>
<!-- Define newer versions of Java compiler and war plugin to
better support latest JDK versions. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
</plugin>
<!--
Take care of synchronizing java dependencies and imports in
package.json and main.js files.
It also creates webpack.config.js if not exists yet.
-->
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>${vaadin.version}</version>
<executions>
<execution>
<goals>
<goal>prepare-frontend</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<!-- Production mode is activated using -Pproduction -->
<id>production</id>
<build>
<plugins>
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>${vaadin.version}</version>
<executions>
<execution>
<goals>
<goal>build-frontend</goal>
</goals>
<phase>compile</phase>
</execution>
</executions>
<configuration>
<productionMode>true</productionMode>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
anyone has any idea why is this happening?
This is the only view/router, Autowiring is not working neither (btw), empresaService is always null
@Route("")
@PageTitle("SAS - DDJJ")
public class MainView extends VerticalLayout {
@Autowired
private EmpresaService empresaService;
public MainView() {
System.out.println("Checking autowiring===" + empresaService);
TextField textField = new TextField("Your name");
textField.addThemeName("bordered");
GreetService greetService = new GreetService();
Button button = new Button("Say hello", e -> {
Notification.show(greetService.greet(textField.getValue()));
});
button.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
button.addClickShortcut(Key.ENTER);
// Use custom CSS classes to apply styling. This is defined in
// shared-styles.css.
addClassName("centered-content");
add(textField, button, new Button("blable", VaadinIcon.ABACUS.create()));