Issue
I've got a problem with deploying my Maven application on the Azure web service. Locally everything works alright, the pipeline's working, and app is deployed, however, whenever I try to see page content on azure websites the response is:
:( Application Error
If you are the application administrator, you can access the diagnostic resources.
Of course, I checked azure logs and that's what I've observed:
2021-05-15T00:41:28.568009808Z at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144) ~[spring-boot-2.4.4.jar!/:2.4.4]
2021-05-15T00:41:28.568014108Z at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:769) ~[spring-boot-2.4.4.jar!/:2.4.4]
2021-05-15T00:41:28.568018408Z at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) ~[spring-boot-2.4.4.jar!/:2.4.4]
2021-05-15T00:41:28.568022608Z at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:426) ~[spring-boot-2.4.4.jar!/:2.4.4]
2021-05-15T00:41:28.568026808Z at org.springframework.boot.SpringApplication.run(SpringApplication.java:326) ~[spring-boot-2.4.4.jar!/:2.4.4]
2021-05-15T00:41:28.568030908Z at org.springframework.boot.SpringApplication.run(SpringApplication.java:1313) ~[spring-boot-2.4.4.jar!/:2.4.4]
2021-05-15T00:41:28.568035108Z at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302) ~[spring-boot-2.4.4.jar!/:2.4.4]
2021-05-15T00:41:28.568039208Z at pl.agh.restaurant_project.RestaurantProjectApplication.main(RestaurantProjectApplication.java:10) ~[classes!/:0.0.1-SNAPSHOT]
2021-05-15T00:41:28.568043408Z at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
2021-05-15T00:41:28.568047508Z at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
2021-05-15T00:41:28.568051708Z at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
2021-05-15T00:41:28.568059308Z at java.base/java.lang.reflect.Method.invoke(Unknown Source) ~[na:na]
2021-05-15T00:41:28.568063808Z at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) ~[app.jar:0.0.1-SNAPSHOT]
2021-05-15T00:41:28.568068008Z at org.springframework.boot.loader.Launcher.launch(Launcher.java:107) ~[app.jar:0.0.1-SNAPSHOT]
2021-05-15T00:41:28.568072408Z at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) ~[app.jar:0.0.1-SNAPSHOT]
2021-05-15T00:41:28.568076608Z at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) ~[app.jar:0.0.1-SNAPSHOT]
2021-05-15T00:41:28.568080808Z Caused by: org.apache.catalina.LifecycleException: A child container failed during start
2021-05-15T00:41:28.568084908Z at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:928) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
2021-05-15T00:41:28.568089208Z at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:843) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
2021-05-15T00:41:28.568093408Z at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
2021-05-15T00:41:28.568097708Z at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
2021-05-15T00:41:28.568102008Z at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
2021-05-15T00:41:28.568106308Z at java.base/java.util.concurrent.FutureTask.run(Unknown Source) ~[na:na]
2021-05-15T00:41:28.568110508Z at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
2021-05-15T00:41:28.568114908Z at java.base/java.util.concurrent.AbstractExecutorService.submit(Unknown Source) ~[na:na]
2021-05-15T00:41:28.568119108Z at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
2021-05-15T00:41:28.568123508Z ... 30 common frames omitted
2021-05-15T00:41:28.568127608Z Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [NonLoginAuthenticator[StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]]
2021-05-15T00:41:28.568144308Z at java.base/java.util.concurrent.FutureTask.report(Unknown Source) ~[na:na]
2021-05-15T00:41:28.568148508Z at java.base/java.util.concurrent.FutureTask.get(Unknown Source) ~[na:na]
2021-05-15T00:41:28.568164008Z at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
2021-05-15T00:41:28.568168308Z ... 38 common frames omitted
2021-05-15T00:41:28.568172308Z Caused by: org.apache.catalina.LifecycleException: Failed to start component [NonLoginAuthenticator[StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]]
2021-05-15T00:41:28.568180008Z at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
2021-05-15T00:41:28.568184908Z at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
2021-05-15T00:41:28.568189108Z at org.apache.catalina.core.StandardPipeline.startInternal(StandardPipeline.java:176) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
2021-05-15T00:41:28.568193308Z at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
2021-05-15T00:41:28.568197508Z at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5094) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
2021-05-15T00:41:28.568201708Z at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
2021-05-15T00:41:28.568205908Z at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
2021-05-15T00:41:28.568210108Z at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
2021-05-15T00:41:28.568214408Z at java.base/java.util.concurrent.FutureTask.run(Unknown Source) ~[na:na]
2021-05-15T00:41:28.568218608Z at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
2021-05-15T00:41:28.568222908Z at java.base/java.util.concurrent.AbstractExecutorService.submit(Unknown Source) ~[na:na]
2021-05-15T00:41:28.568227108Z at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
2021-05-15T00:41:28.568231308Z ... 38 common frames omitted
2021-05-15T00:41:28.568235308Z Caused by: java.lang.NoSuchMethodError: 'java.lang.String javax.servlet.ServletContext.getVirtualServerName()'
2021-05-15T00:41:28.568239508Z at org.apache.catalina.authenticator.AuthenticatorBase.startInternal(AuthenticatorBase.java:1355) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
2021-05-15T00:41:28.568243808Z at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
2021-05-15T00:41:28.568260608Z ... 48 common frames omitted
I had problems with servlets before, but with exclucions I was able to remove error below:
Caused by: java.lang.NoSuchMethodError: 'java.lang.String javax.servlet.ServletContext.getVirtualServerName()'
The occurring of this problem is very confusing to me and honestly, I am out of ideas on how to fix this.
Below, I attach POM.xml and azure.yml:
azure.yml
name: Build and deploy JAR app to Azure Web App - thepierogi
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Java version
uses: actions/setup-java@v1
with:
java-version: '11'
- name: Build with Maven
run: mvn clean install
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v2
with:
name: java-app
path: '${{ github.workspace }}/target/*.jar'
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v2
with:
name: java-app
- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: 'thepierogi'
slot-name: 'production'
publish-profile: ${{ secrets.AzureAppService_PublishProfile_af0b43cf31c64844acb8e748c96899db }}
package: '*.jar'
POM.xml
<?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.4.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>pl.agh</groupId>
<artifactId>restaurant_project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>restaurant_project</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.3</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.mortbay.jetty</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.4.4</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<version>2.3.3.RELEASE</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>2.7.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>5.3.5</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.3.156</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>9.2.1.jre15</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
<version>3.0.12.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
<version>2.4.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-context-support -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>5.3.6</version>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.13.1</version>
</dependency>
<dependency>
<groupId>net.sf.supercsv</groupId>
<artifactId>super-csv</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>org.seedstack.addons.io</groupId>
<artifactId>io-supercsv</artifactId>
<version>3.0.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.9.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
</plugin>
</plugins>
</build>
</project>
Thank you in advance for your help!
Solution
Check application logs like below.
You will find you missing startup command. In logs, it will show you like below:
2021-05-16T16:07:34.95**Z No STARTUP_FILE available.
2021-05-16T16:07:34.95**Z No STARTUP_COMMAND defined.
2021-05-16T16:07:35.01**Z Made a local copy of the app and using APP_JAR_PATH=/local/site/wwwroot/app.jar
2021-05-16T16:07:35.01**Z Running command: java -Dserver.port=80 -jar /local/site/wwwroot/app.jar
So you can add startup command to slove the issue.
Offical doc:
Related Blog
2. Deploying Helidon applications to Azure App Service
Answered By - Jason Pan