-
Notifications
You must be signed in to change notification settings - Fork 143
Deployment Instructions for MSAL Java Samples
MSAL Java can be deployed to a number of web and application servers. Although the exact build and deployment steps will depend on your environment and existing set up, here are instructions for running our MSAL Java samples on some popular web/app servers.
All of our samples can be built using Maven. Navigate to the directory containing the pom.xml file for the project (typically the same as the main README if your trying to run our samples), and run the following Maven command:
mvn clean package
This should generate a .war file which can be run on a variety of web/app servers
Before you build the package, note that most samples' configuration files and README instructions use http://localhost:8080
or https://localhost:8443
as the default redirect URL. These ports work for Apache Tomcat and possibly the built-in app servers when running directly from your IDE, however some enterprise app servers such as Weblogic, JBoss, and Websphere use different default ports. In order to run a sample on these servers you will need to change the configuration in certain files and in the Azure app registration for that sample, and the instructions below include where to make those changes and what the default ports likely are.
(These instructions assume you have installed Tomcat on your system)
To run the sample on Tomcat:
-
In your Tomcat installation, ensure there is a entry in tomcat/conf/server.xml for the address you want to host your application on
- By default, our samples just expect to connect to
http://localhost:8080
orhttps://localhost:8443
, as defined in the app.homePage value in authentication.properties file
- By default, our samples just expect to connect to
-
Copy the .war file you generated with Maven to the /webapps/ directory in your Tomcat installation, and start the Tomcat server
-
Once Tomcat starts, open your browser and navigate to whatever URL you defined in step 1, and you should be able to access the application
(These instructions assume you have installed WebLogic and set up some server domain)
Before you can deploy to WebLogic, you will need to make some configuration changes in the sample itself and (re)build the package:
-
In the sample there is likely an
application.properties
orauthentication.properties
file where you configured the client ID, tenant, redirect URL, etc. -
In the above mentioned file, changed references to
localhost:8080
orlocalhost:8443
to the URL/port WebLogic will run on, which by default should belocalhost:7001
-
You will also need to make the same change in the Azure app registration, where you set it as the 'Redirect URI' in the 'Authentication' tab
To deploy the sample to WebLogic via the web console:
-
Start the WebLogic server with DOMAIN_NAME\bin\startWebLogic.cmd
-
Navigate to the WebLogic web console in your browser,
http://localhost:7001/console
-
Go to Domain Structure > Deployments, click Install, click upload your files, and find the .war file you built with Maven
-
Select Install this deployment as an application, click Next, click Finish, and then Save
- Most of the default settings should be fine except that you should name the application to match the 'Redirect URI' you set in sample configuration/Azure app registration, i.e. if the redirect URI is
http://localhost:7001/msal4j-servlet-auth
then you should name the application 'msal4j-servlet-auth'
- Most of the default settings should be fine except that you should name the application to match the 'Redirect URI' you set in sample configuration/Azure app registration, i.e. if the redirect URI is
-
Go back to Domain Structure > Deployments, and Start your application
-
Once the application starts, navigate to
http://localhost:7001/{whatever you named the application}/
, and you should be able to access the application
Before you can deploy to JBoss, you will need to make some configuration changes in the sample itself and (re)build the package:
-
In the sample there is likely an
application.properties
orauthentication.properties
file where you configured the client ID, tenant, redirect URL, etc. -
In the above mentioned file, changed references to
localhost:8080
orlocalhost:8443
to the URL/port JBoss will run on, which by default should belocalhost:9990
-
You will also need to make the same change in the Azure app registration, where you set it as the 'Redirect URI' in the 'Authentication' tab
To deploy the sample to JBoss EAP via the web console:
-
Start the JBoss server with %JBOSS_HOME%\bin\standalone.bat
-
Navigate to the JBoss web console in your browser,
http://localhost:9990
-
Go to Deployments, click Add, and upload the .war you built
-
Most of the default settings should be fine except that you should name the application to match the 'Redirect URI' you set in sample configuration/Azure app registration, i.e. if the redirect URI is
http://localhost:9990/msal4j-servlet-auth/
then you should name the application 'msal4j-servlet-auth' -
Select the .war file you uploaded, click En/Disable, and Confirm to start the application
-
Once the application starts, navigate to
http://localhost:9990/{whatever you named the application}/
, and you should be able to access the application
(These instructions assume you have installed Websphere and set up some server ) Before you can deploy to Websphere, you will need to make some configuration changes in the sample itself and (re)build the package:
- In the sample there is likely an
application.properties
orauthentication.properties
file where you configured the client ID, tenant, redirect URL, etc. - In the above mentioned file, changed references to
localhost:8080
orlocalhost:8443
to the URL/port Websphere will run on, which by default should belocalhost:9080
- You will also need to make the same change in the Azure app registration, where you set it as the 'Redirect URI' in the 'Authentication' tab
Top deploy the sample using the Websphere's Integrated Solutions Console:
-
In the 'Applications' tab, select 'New Application', then 'New Enterprise Application'
-
Choose the .war you built, then click 'next' until you get to the 'Map context roots for Web modules' installation step (the other default settings should be fine)
-
For the context root, set it to the same value as after the port number in the 'Redirect URI' you set in sample configuration/Azure app registration, i.e. if the redirect URI is
http://localhost:9080/msal4j-servlet-auth/
then the context root should just be 'msal4j-servlet-auth' -
Click 'Finish', and after the application finishes installing go to the 'Websphere enterprise applications' section of the 'Applications' tab
-
Select the .war you just installed from the list of applications and click 'Start' to deploy
-
One it finishes deploying, navigate to
http://localhost:9080/{whatever you set as the context root}
and you should be able to see the application
- Home
- Why use MSAL4J
- Register your app with AAD
- Scenarios
- Client Applications
- Acquiring tokens
- IAuthenticationResult
- Calling a protected API