Hello Sven Auer,
Welcome to the Microsoft Q&A and thank you for posting your questions here.
I understand that you would like to deploy Java app to Azure App Service and you want to know how you can add "javax.mail.jar", "mysql-connector-j-9.0.0.jar" and the context.xml to an Azure App Service with Java 11 and Tomcat 9.
It starts with your code plartform:
- Download the MySQL Connector/J JDBC driver from the https://dev.mysql.com/downloads/connector/j follow the instruction and add the following dependency to your
pom.xml
file:
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>9.0.0</version>
https://www.digitalocean.com/community/tutorials/javamail-example-send-mail-in-java-smtp
- Download the latest version of the JavaMail reference implementation from https://www.oracle.com/java/technologies/javamail.html include the
javax.mail.jar
in your project's build path and add the following dependency to yourpom.xml
file:
<dependency>
<groupId>javax.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>x.y.z</version>
</dependency>
Then, create a context.xml file for your web application (usually located in the META-INF
directory). In this file you will define your database connection settings, such as the data source, username, password, and other relevant properties. For a sample it looks like:
<Context>
<Resource name="jdbc/MyDB" auth="Container"
type="javax.sql.DataSource"
driverClassName="com.mysql.cj.jdbc.Driver"
url="jdbc:mysql://your-mysql-server:3306/your-database"
username="your-username"
password="your-password"
maxTotal="20"
maxIdle="10"
maxWaitMillis="-1"/>
</Context>
Finally, deploy your Java application (WAR file) to your Azure App Service and make sure the context.xml
file is included in your deployment package. After this, ensure you configure the Azure App Service to use Java 11 and Tomcat 9.
I hope this is helpful! Do not hesitate to let me know if you have any other questions.
** Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful ** so that others in the community facing similar issues can easily find the solution.
Best Regards,
Sina Salam