How to fix tomcat issue on Azure Portal?

farrukh izhar 0 Reputation points
2025-03-10T08:01:00.16+00:00

I developed a Java JSP web application that includes:

Servlets

JSP Pages

Models and Controllers

The web application runs successfully on a local environment with a local database.

To deploy the application on Azure, I followed the steps outlined below:

Created a Resource Group.

Configured the Web App by specifying details such as the app name, stack, and server.

Set Up the Database by providing the server name, username, and password.

Configured Networking, allowing public access by adding client addresses and IP addresses.

Enabled FTPS Authentication for secure file transfer.

Reviewed and created the Web App.

Once the Azure Web App was set up, I verified the database connection using MySQL Workbench. I created a database and uploaded the tables and data into the database.

I successfully ran the application on a local Tomcat server, and the login functionality worked as expected.

Next, I deployed the application by uploading the WAR file using FTPS credentials via FileZilla. After restarting the application on Azure, the web app ran successfully. However, when attempting to log in, the application crashed, giving a 400 error.1

2

3

4

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,444 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Siva Nair 735 Reputation points Microsoft External Staff
    2025-03-11T12:29:02.48+00:00

    Hi farrukh izhar,

    Make sure Tomcat and Java versions on Azure are the same as you had locally. Verify this under App Service → Configuration → General Settings. Then, ensure your WAR file is properly deployed and unzipped under /site/wwwroot/webapps/, with good folder hierarchy such as WEB-INF, lib, and JSP files.

    Validate database connection strings — utilize the Azure MySQL FQDN, correct username syntax (e.g., user@servername), and securely store credentials in App Settings, not in code. Ensure Azure Database firewall permits connections from your App Service.

    Enable and verify Log Stream for live logs to catch errors and verify servlet mappings or request problems responsible for the 400 error. Ensure form actions in JSPs are correct servlet URL patterns and doPost methods process requests correctly.

    Verify that all necessary JARs (e.g., MySQL connector) are in WEB-INF/lib/. Also, examine Azure App Service configurations to make sure there are no resource caps or HTTP constraints on Tomcat.

    Last, use a straightforward "Hello World" JSP to verify if Tomcat executes properly. If that succeeds, concentrate on repairing problems in your app code, servlet mappings, or configurations.

    https://learn.microsoft.com/en-us/azure/app-service/configure-language-java-deploy-run?pivots=java-javase&tabs=windows

    If you have any further assistant, do let me know. If possible please do share the exact 400 error message to help you more.


  2. Siva Nair 735 Reputation points Microsoft External Staff
    2025-03-12T21:36:24.8866667+00:00

    Hi farrukh izhar,

    Thanks for sharing the error message,“404 Page Not Found". This can happen for various reasons, such as a missing or misconfigured startup file, incorrect routing rules, or a deployment issue.

    1. confirm that your application actually deployed successfully. In the Azure Portal, go to your App Service, then select Deployment Center (or Deployment in some versions) and check the deployment logs for any errors. You should also look at the App Service logs (under Monitoring → Log Stream or App Service logs) to see if the application is failing to start. If your logs indicate that the application crashed or could not find certain files, fix those issues locally and redeploy.
    2. verify that your application’s startup configuration is correct. For an ASP.NET or ASP.NET Core application, ensure that the "web.config" file is present and points to the correct assemblies, or that your "Program.cs" or "Startup.cs" defines the appropriate route for the root URL. If you’re using Node.js, confirm that your main file (often index.js) is in the correct location and that you are letting Azure set the port via "process.env.PORT". if its Python-based frameworks such as Flask or Django, check that your app’s entry point is configured properly and that your URL patterns include a route for the root path (/).
    3. It is also crucial to enable diagnostic logging, as the error message suggests. Within the Azure Portal, open your App Service and go to Diagnostics settings or App Service logs, then enable Application Logging (Filesystem) or Application Logging (Blob). This will help you capture more detailed information on whether the application is encountering exceptions during startup or failing to serve particular routes.
    4. If your application relies on environment variables (for example, database connection strings or external service credentials), verify that they are set correctly in the Configuration → Application Settings section of your App Service. In addition, if you use a custom domain, ensure that the DNS records are properly configured and that the domain is mapped in the Custom domains blade of your App Service. Check any rewrite or redirect rules (e.g., in a "web.config" file or reverse proxy settings) to make sure they do not inadvertently direct requests to a non-existent path. If you have any further assistant, do let me know

    If the answer is helpful, please click Accept Answer and kindly upvote it so that other people who faces similar issue may get benefitted from it.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.