Unable to run sample Web Application in Azure App Service (Linux)

RASHID, Mohammad 6 Reputation points
2022-10-14T00:02:03.577+00:00

Hello All,

I've been having trouble for the past several days deploying an example Java application in AppService on a Linux environment using Tomcat.
The application is built and deployed correctly in the Azure app service when I use the usual Maven build and deploy workflow using pipeline.
Meanwhile, when I try to access the url, all I can see is my application's index page; however, the url /SpringWeb/hello returns a 404 error. The application functions flawlessly on my personal Tomcat server.

My application is located in the home/site/wwwroot/webapps folder, however when I check the value for $CATALINA BASE, it is /usr/local/tomcat.

Moreover, I cannot find my application in the /usr/local/tomcat/webapps directory.

I get some catalina log which I believe is relevant to my problem

2022-10-11T04:56:09.082697035Z: [ERROR] Picked up JAVA_TOOL_OPTIONS: -Xmx716M -Djava.net.preferIPv4Stack=true
2022-10-11T04:56:10.260009499Z: [ERROR] Oct 11, 2022 4:56:10 AM org.apache.catalina.startup.ClassLoaderFactory validateFile
2022-10-11T04:56:10.260058400Z: [ERROR] WARNING: Problem with directory [/home/tomcat/lib], exists: [false], isDirectory: [false], canRead: [false]
2022-10-11T04:56:10.261785926Z: [ERROR] Oct 11, 2022 4:56:10 AM org.apache.catalina.startup.ClassLoaderFactory validateFile
2022-10-11T04:56:10.261802626Z: [ERROR] WARNING: Problem with directory [/home/tomcat/lib], exists: [false], isDirectory: [false], canRead: [false]
2022-10-11T04:56:10.271355772Z: [ERROR] Oct 11, 2022 4:56:10 AM org.apache.catalina.startup.ClassLoaderFactory validateFile
2022-10-11T04:56:10.271372272Z: [ERROR] WARNING: Problem with directory [/home/site/libs], exists: [false], isDirectory: [false], canRead: [false]
2022-10-11T04:56:10.279781601Z: [ERROR] Oct 11, 2022 4:56:10 AM org.apache.catalina.startup.ClassLoaderFactory validateFile
2022-10-11T04:56:10.279797001Z: [ERROR] WARNING: Problem with directory [/home/site/libs], exists: [false], isDirectory: [false], canRead: [false]

Does anyone have similar issue? Please advise me on this.

Regards,
Mohammad

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,041 questions
{count} vote

3 answers

Sort by: Most helpful
  1. ajkuma 22,851 Reputation points Microsoft Employee
    2022-10-17T19:44:46.86+00:00

    Apologies for the delay from over the weekend.

    1/2

    Thanks for the follow-up and update. I understand your WebApp works fine on Windows but not on Linux.

    By default, App Service expects your JAR application to be named app.jar. If it has this name, it will be run automatically. For Maven users, you can set the JAR name by including <finalName>app</finalName> in the <build> section of your pom.xml

    Review pom.xml & verifiy the packaging type is “war” and spring-boot-starter-tomcat is set to “provided”

    To use a different name for your JAR, you must also provide the Startup Command that executes your JAR file.
    For example, java -jar my-jar-app.jar. You can set the value for your Startup Command in the Portal, under Configuration > General Settings, or with an Application Setting named STARTUP_COMMAND.

    Tomcat: the location of a script to perform any necessary configurations (for example, /home/site/deployments/tools/startup_script.sh)
    Java SE: the command to start your JAR app

    (for example, java -jar /home/site/wwwroot/app.jar --server.port=80)

    Azure will automatically map Internet requests to embedded Tomcat server that is running on the port - 80. However, if you configured your embedded Tomcat server to run on port - 8080 or custom port, you need to add an environment variable to your web app that defines the port for your embedded Tomcat server.

    In the Application settings section, add a new setting named WEBSITES_PORT and enter your custom port number for the value.


  2. Kone Ibrahim - Cincinnati-AMIG 1 Reputation point
    2022-11-09T22:32:22.14+00:00

    We are facing the same issue. Everything used to work fine, and nothing have changed in our end. we've tried using the CLI to deploy war file without success. Downgrading tomcat did not work either. Both Linux and Windows environment are not working for us.

    Here's the log from the webapp:

    2022-11-09T21:30:35.373504121Z: [INFO] Using app.war with SITEROOT=/usr/local/tomcat/webapps
    2022-11-09T21:30:35.374746929Z: [INFO] Add public certificates to keystore if exists...
    2022-11-09T21:30:35.375413534Z: [INFO] Add private certificates to keystore if exists...
    2022-11-09T21:30:35.377549048Z: [INFO] Configuring max heap = 2399 MB
    2022-11-09T21:30:35.402031716Z: [INFO] STARTUP_FILE=
    2022-11-09T21:30:35.403597427Z: [INFO] STARTUP_COMMAND=
    2022-11-09T21:30:35.403899129Z: [INFO] No STARTUP_FILE available.
    2022-11-09T21:30:35.405427840Z: [INFO] No STARTUP_COMMAND defined.
    2022-11-09T21:30:35.405446640Z: [INFO] Starting Tomcat with CATALINA_BASE set to ""
    2022-11-09T21:30:35.405957443Z: [INFO] Launched child process with pid: 136
    2022-11-09T21:30:35.406720249Z: [INFO] Waiting for main process to exit. GLOBAL_PID_MAIN=136
    2022-11-09T21:30:35.407035251Z: [INFO] Waiting for GLOBAL_PID_MAIN == 136
    2022-11-09T21:30:35.471508193Z: [ERROR] Picked up JAVA_TOOL_OPTIONS: -Xmx2399M -Djava.net.preferIPv4Stack=true
    2022-11-09T21:30:35.851877103Z: [ERROR] Nov 09, 2022 4:30:35 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
    2022-11-09T21:30:35.851954203Z: [ERROR] WARNING: Problem with directory [/home/tomcat/lib], exists: [false], isDirectory: [false], canRead: [false]
    2022-11-09T21:30:35.854271819Z: [ERROR] Nov 09, 2022 4:30:35 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
    2022-11-09T21:30:35.854290119Z: [ERROR] WARNING: Problem with directory [/home/tomcat/lib], exists: [false], isDirectory: [false], canRead: [false]
    2022-11-09T21:30:35.857613742Z: [ERROR] Nov 09, 2022 4:30:35 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
    2022-11-09T21:30:35.857683843Z: [ERROR] WARNING: Problem with directory [/home/site/libs], exists: [false], isDirectory: [false], canRead: [false]
    2022-11-09T21:30:35.860277960Z: [ERROR] Nov 09, 2022 4:30:35 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
    2022-11-09T21:30:35.860297861Z: [ERROR] WARNING: Problem with directory [/home/site/libs], exists: [false], isDirectory: [false], canRead: [false]
    2022-11-09T21:30:36.387176073Z: [INFO] Nov 09, 2022 4:30:36 PM org.apache.catalina.startup.VersionLoggerListener log
    2022-11-09T21:30:36.387210873Z: [INFO] INFO: Server version name: Apache Tomcat/9.0.62


  3. RASHID, Mohammad 6 Reputation points
    2022-11-25T01:14:15.24+00:00

    I can see some people are experiencing the similar issue.

    Thank you @ajkuma for your solutions But really we don't have the scope to alter or modify something in the environment.
    We want to deploy the application (WAR deploy) using either AzureWebApp@1 or AzureRmWebAppDeployment@4 task in deploy pipeline.

    Using the Windows App service plan it all works fine.

    So please let me know what to change if I want to use those tasks..

    FYI, changing to app.war doesn't work for me...

    Thank you