You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/app-service/tutorial-java-tomcat-mysql-app.md
+23-8Lines changed: 23 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -82,6 +82,8 @@ For your convenience, the [sample repository](https://github.com/Azure-Samples/m
82
82
:::column-end:::
83
83
:::row-end:::
84
84
85
+
Having issues? Check the [Troubleshooting section](#troubleshooting).
86
+
85
87
::: zone pivot="azure-portal"
86
88
87
89
## 2. Create App Service and MySQL
@@ -114,7 +116,7 @@ Sign in to the [Azure portal](https://portal.azure.com/) and follow these steps
114
116
1. *Region*: Any Azure region near you.
115
117
1. *Name*: **msdocs-tomcat-mysql-XYZ** where *XYZ* is any three random characters. This name must be unique across Azure.
116
118
1. *Runtime stack*: **Java 17**.
117
-
1. *Java web server stack*: **Apache Tomcat 10.0**.
119
+
1. *Java web server stack*: **Apache Tomcat 10.1**.
118
120
1. **MySQL - Flexible Server** is selected for you by default as the database engine. If not, select it. Azure Database for MySQL is a fully managed MySQL database as a service on Azure, compatible with the latest community editions.
119
121
1. *Hosting plan*: **Basic**. When you're ready, you can [scale up](manage-scale-up.md) to a production pricing tier later.
120
122
1. Select **Review + create**.
@@ -139,6 +141,8 @@ Sign in to the [Azure portal](https://portal.azure.com/) and follow these steps
139
141
:::column-end:::
140
142
:::row-end:::
141
143
144
+
Having issues? Check the [Troubleshooting section](#troubleshooting).
145
+
142
146
## 3. Verify connection settings
143
147
144
148
The creation wizard generated the connectivity string for you already as [app settings](configure-common.md#configure-app-settings). In this step, you learn where to find the app settings, and how you can create your own.
@@ -368,14 +372,14 @@ When you're finished, you can delete all of the resources from your Azure subscr
368
372
369
373
In this step, you create the Azure resources and deploy a sample app to App Service on Linux. The steps used in this tutorial create a set of secure-by-default resources that include App Service and Azure Database for MySQL.
370
374
371
-
1.If you haven't already, clone the sample repository's `starter-no-infra` branch in a local terminal.
375
+
1.In the GitHub codspace of your sample fork, get the remote `starter-no-infra` branch by running the following code in the terminal.
This cloned branch is your starting point. It contains a simple data-drive Tomcat application.
382
+
This branch is your starting point. It contains a simple data-drive Tomcat application.
379
383
380
384
1. From the repository root, run `azd init`.
381
385
@@ -403,7 +407,7 @@ In this step, you create the Azure resources and deploy a sample app to App Serv
403
407
azd up
404
408
```
405
409
406
-
The `azd up`command takes about 15 minutes to complete (the database and the cache take the most time). It also compiles and deploys your application code, but you'll modify your code later to work with App Service. While it's running, the command provides messages about the provisioning and deployment process, including a link to the deployment in Azure. When it finishes, the command also displays a link to the deploy application.
410
+
The `azd up`command takes about 15 minutes to complete (the Redis cache take the most time). It also compiles and deploys your application code, but you'll modify your code later to work with App Service. While it's running, the command provides messages about the provisioning and deployment process, including a link to the deployment in Azure. When it finishes, the command also displays a link to the deploy application.
407
411
408
412
This azd template contains files (*azure.yaml* and the *infra* directory) that generate a secure-by-default architecture with the following Azure resources:
409
413
@@ -456,7 +460,7 @@ In this step, you use the SSH connection to the app container to verify the JNDI
456
460
457
461
## 5. Modify sample code and redeploy
458
462
459
-
1. Back in the GitHub codespace of your sample fork, open *src/main/java/com/microsoft/azure/appservice/examples/tomcatmysql/ContextListener.java* in the explorer. When the application starts, this class loads the database settings in *src/main/resources/META-INF/persistence.xml*.
463
+
1. Back in the GitHub codespace of your sample fork, from the explorer, open *src/main/java/com/microsoft/azure/appservice/examples/tomcatmysql/ContextListener.java*. When the application starts, this class loads the database settings in *src/main/resources/META-INF/persistence.xml*.
460
464
461
465
1. In the `contextIntialized()` method, find the commented code (lines 29-33) and uncomment it.
462
466
@@ -470,12 +474,15 @@ In this step, you use the SSH connection to the app container to verify the JNDI
470
474
471
475
This code checks to see if the `AZURE_MYSQL_CONNECTIONSTRING` app setting exists, and changes the data source to `java:comp/env/jdbc/AZURE_MYSQL_CONNECTIONSTRING_DS`, which is the data source you found earlier in *context.xml* in the SSH shell.
472
476
473
-
1. In the terminal, run `azd deploy`.
477
+
1. Back in the codespace terminal, run `azd deploy`.
474
478
475
479
```bash
476
480
azd deploy
477
481
```
478
482
483
+
> [!TIP]
484
+
> You can also just use `azd up` always, which does both `azd provision` and `azd deploy`.
485
+
479
486
## 6. Browse to the app
480
487
481
488
1. In the azd output, find the URL of your app and navigate to it in the browser. The URL looks like this in the AZD output:
@@ -521,10 +528,18 @@ azd down
521
528
522
529
## Troubleshooting
523
530
531
+
- [I see many \<Class> scanned from multiple locations warnings with mvn jetty:run](#i-see-many-class-scanned-from-multiple-locations-warnings-with-mvn-jettyrun)
532
+
- [The deployed sample app doesn't show the tasks list app](#the-deployed-sample-app-doesnt-show-the-tasks-list-app)
533
+
- [The portal deployment view for Azure Database for MySQL Flexible Server shows a Conflict status](#the-portal-deployment-view-for-azure-database-for-mysql-flexible-server-shows-a-conflict-status)
534
+
524
535
#### I see many \<Class> scanned from multiple locations warnings with mvn jetty:run
525
536
526
537
You can ignore the warnings. The Maven Jetty plugin shows the warnings because the app's *pom.xml* contains the dependency for`jakarta.servlet.jsp.jstl`, which the Jetty already provides out of the box. You need the dependency for Tomcat.
527
538
539
+
#### The deployed sample app doesn't show the tasks list app
540
+
541
+
If you see a `Hey, Java developers!` page instead of the tasks list app, it's most likely still loading the updated container from your most recent code deployment. Wait a few minutes and try again.
542
+
528
543
#### The portal deployment view for Azure Database for MySQL Flexible Server shows a Conflict status
529
544
530
545
Depending on your subscription and the region you select, you may see the deployment status for Azure Database for MySQL Flexible Server to be `Conflict`, with the following message in Operation details:
0 commit comments