0

I'm trying to build a WAR file for my maven project which I used vaadin framework inside. When I run project in eclipse with jetty:run project runs smoothly. But when I tried to create a WAR file and deploy it to Apcahe Tomcat 10 I get the 404 Not Found error. When I searched online nearly every solution about the index.jsp file but I don't have an index.jsp file in my project. Packaging WAR is added in my pom.xml file. In mavens site the proper maven directory shows as follows enter image description here

But my directory is not same with the one here. I don't have web.xml and index.jsp file. It's probably because of the vaadin framework but I cant find a way to deploy project. Can anyone help me about this problem?

Thank you.

my pom.xml file looks like this.

<?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.example.project</groupId>
<artifactId>projectProgram</artifactId>
<name>projectProgram</name>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>

<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <failOnMissingWebXml>false</failOnMissingWebXml>

    <vaadin.version>14.6.6</vaadin.version>
    <jetty.version>9.4.15.v20190215</jetty.version>
</properties>

<pluginRepositories>
    <!-- Repository needed for using Vaadin prerelease versions
    <pluginRepository>
        <id>vaadin-prereleases</id>
        <url>https://maven.vaadin.com/vaadin-prereleases</url>
    </pluginRepository>
     -->
</pluginRepositories>

<repositories>
    <repository>
        <id>central</id>
        <url>https://repo.maven.apache.org/maven2</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>vaadin-addons</id>
        <url>https://maven.vaadin.com/vaadin-addons</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
    <!-- Repository needed for using Vaadin prerelease versions <repository>
        <id>vaadin-prereleases</id>
        <url>https://maven.vaadin.com/vaadin-prereleases</url>
    </repository>
    -->
</repositories>

<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>
        <artifactId>vaadin</artifactId>
        <exclusions>
            <!-- Webjars are only needed when running in Vaadin 13 compatibility mode -->
            <exclusion>
                <groupId>com.vaadin.webjar</groupId>
                <artifactId>*</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.webjars.bowergithub.insites</groupId>
                <artifactId>*</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.webjars.bowergithub.polymer</groupId>
                <artifactId>*</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.webjars.bowergithub.polymerelements</groupId>
                <artifactId>*</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.webjars.bowergithub.vaadin</groupId>
                <artifactId>*</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.webjars.bowergithub.webcomponents</groupId>
                <artifactId>*</artifactId>
            </exclusion>
        </exclusions>
    </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>3.8.1</version>
        <scope>test</scope>
    </dependency>

    <!-- Added to provide logging output as Flow uses -->
    <!-- the unbound SLF4J no-operation (NOP) logger implementation -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

<build>
    <defaultGoal>jetty:run</defaultGoal>
    <plugins>
        <plugin>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>${jetty.version}</version>
            <configuration>
                <scanIntervalSeconds>1</scanIntervalSeconds>
            </configuration>
        </plugin>
        <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>
        <id>it</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-maven-plugin</artifactId>
                    <configuration>
                        <stopPort>9966</stopPort>
                        <stopKey>stopit</stopKey>
                        <scanIntervalSeconds>-1</scanIntervalSeconds>
                    </configuration>
                    <executions>
                        <execution>
                            <id>start-jetty</id>
                            <phase>pre-integration-test</phase>
                            <goals>
                                <goal>start</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>stop-jetty</id>
                            <phase>post-integration-test</phase>
                            <goals>
                                <goal>stop</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>2.22.2</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>integration-test</goal>
                                <goal>verify</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <trimStackTrace>false</trimStackTrace>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>
    <profile>
        <!-- Production mode is activated using -Pproduction -->
        <id>production</id>
        <properties>
            <vaadin.productionMode>true</vaadin.productionMode>
        </properties>
        <dependencies>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>flow-server-production-mode</artifactId>
            </dependency>
        </dependencies>
        <build>
            <plugins>
                <plugin>
                    <groupId>com.vaadin</groupId>
                    <artifactId>vaadin-maven-plugin</artifactId>
                    <version>${vaadin.version}</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>build-frontend</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>
Jiraiya
  • 101
  • 1
  • 9
  • How did you create the project? And how does your pom.xml look like? – Simon Martinelli Aug 02 '21 at 07:04
  • 2
    Vaadin does not work with Tomcat 10 or any Servlet 5.0 container. Check, e.g. [this answer](https://stackoverflow.com/q/66806582/11748454) for the reason. Your JSPs on the other hand should work if they don't contain scriptlets. – Piotr P. Karwasz Aug 02 '21 at 07:17
  • @PiotrP.Karwasz if I downgrade the tomcat version to 9 will it be okay or this is a general problem in vaadin projects? I don't have jsp files in my project. – Jiraiya Aug 02 '21 at 07:59
  • @SimonMartinelli i updated the question and added the pom.xml file – Jiraiya Aug 02 '21 at 08:04
  • 2
    @Jiraiya: yes, Tomcat 9.0 will work. There is a disruptive change propagating through the Java EE community (cf. [this article](https://eclipse-foundation.blog/2020/12/08/jakarta-ee-9-delivers-the-big-bang/)). Software libraries are either pre-Jakarta EE 9 or post-Jakarta EE 9. You can not mix them. Vaadin, as most libraries, still uses Java EE 8/Jakarta EE 8. – Piotr P. Karwasz Aug 02 '21 at 08:11
  • How did you create this project? – Simon Martinelli Aug 02 '21 at 08:17

1 Answers1

0

Thanks to @PiotrP.Karwasz I downgrade the tomcat version to Tomcat9 from Tomcat10 and that solved the problem.

Jiraiya
  • 101
  • 1
  • 9