0

I'm trying to run Vaadin app on azure and I constantly getting error 404. It's basic app with only 2 classes - from spring initializr and one my class.

 import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class WsbProjektZalApplication {

    public static void main(String[] args) {
        SpringApplication.run(WsbProjektZalApplication.class, args);
    }

}


import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

public class ServletInitializer extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(WsbProjektZalApplication.class);
    }

}

And one my class

import com.vaadin.flow.component.html.H1;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.router.Route;

@Route("/co")
public class ListView extends VerticalLayout {

    public ListView() {
        add(new H1("dziaƂa chyba totto"));
    }

}

My pom file is default and I wasn't editing it.

 ?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.0</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>zaliczenie</groupId>
    <artifactId>wsb-projekt-zal</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>wsb-projekt-zal</name>
    <description>wsb-projekt-zal</description>
    <properties>
        <java.version>17</java.version>
        <vaadin.version>23.0.10</vaadin.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-spring-boot-starter</artifactId>
        </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-bom</artifactId>
            <version>${vaadin.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>

    </plugins>
</build>

I'm trying to run this app with war artifacts on tomcat 9. Problems occur only with Vaadin, I can run this app locally without any problems. Can somebody help me and tell me where I'm making mistake? Screen of error below. enter image description here

Kjean
  • 1

1 Answers1

0

Try to resolve the error by adding the following in $TOMCAT_HOME/conf/server.xml
To avoid memory leaks, Tomcat disables the loading of Java driver files by default.

<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" driverManagerProtection="false" />

Also, if you're creating a spring boot application, add "SpringBootServletInitializer" to your main file, as seen in the code below. As without SpringBootServletInitializer, Tomcat will see it as a regular application rather than a Spring boot application.

@SpringBootApplication
public class DemoApplication extends *SpringBootServletInitializer*{

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
         return application.sources(DemoApplication .class);
    }

    public static void main(String[] args) {
         SpringApplication.run(DemoApplication .class, args);
    }
}

References:
The origin server did not find a current representation for the target resource or is not willing to disclose that one exists ,
Tomcat 404 error: The origin server did not find a current representation for the target resource or is not willing to disclose that one exists [duplicate]