Home > Blockchain >  uploading the war file to Azure web app, 404 error
uploading the war file to Azure web app, 404 error

Time:05-12

In an attempt to learn and publish the war file to azure web app, I am using Azure Cli and publishing the war file. I followed the below article from microsoft documents.

enter image description here

when I checked the files in kudu. I do see the file is updated but the name has changed to app.war rather than what was provided in the cli command.

When I visited the site, it gave me 404. Prior to uploading the war file, when I visited the site it was an empty page and nothing else but now I am getting error.

My app service is using Java 17 on Linux and Tomcat is the server.

enter image description here

Below are the available files after I uploaded the war file

enter image description here

Update: Although I access the kudu but it is not as usual as because I don't see debug console.

enter image description here

CodePudding user response:

when I checked the files in kudu. I do see the file is updated but the name has changed to app.war rather than what was provided in the cli command.

  • The enter image description here

    CodePudding user response:

    In the off chance someone is attempting to deploy Spring Boot as a WAR file, the following applies to deploying Spring Boot applications as WAR. The CLI commands remain universal, however. Also note, since one would no longer using the embedded Tomcat server, must deploy to Java Tomcat, not Java SE.

    Firstly, in my pom file I verified the following:

    <packaging>war</packaging>
    

    and

    <dependency>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-tomcat</artifactId>
       <scope>provided</scope><!-- THIS LINE MUST BE PRESENT -->
    </dependency>
    

    And in my code, I extended SpringBootInitializer:

    public class DwBootJarApplication extends SpringBootServletInitializer {
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(DwBootJarApplication.class);
    }
    public static void main(String[] args) {
        SpringApplication.run(DwBootJarApplication.class, args);
    }
    

    And finally, from command line in project root, to configure pom for Azure:

    mvn com.microsoft.azure:azure-webapp-maven-plugin:2.2.3:config

    and to deploy:

    mvn package azure-webapp:deploy

    This is not the only way to deploy, but it is what I find most convenient and is "officially" recommended for development stage of activities.

    One final note, it is considered best practice to "pin" Java / Tomcat minor versions to a specific version and not auto update.

  • Related