loading...empty;done;/play-framework-deploy/:-uriPlay Framework Deployment | iNET.elastic Dev Docs

Play Framework for Web Application Development

Play is one of the most popular frameworks powered by Java, which integrates components and APIs for modern web application development.

In this tutorial, you’ll see how to deploy Play at the platform without any code changes.

1. Java 8 is required for using the Play framework, so let’s create a suitable environment. For example, we’ll use the Oracle OpenJDK 8.0.22 version of the Tomcat application server.

create java 8 environment for play framework

2. Once the environment is ready, you can deploy your Play application. We are using the following Hello World package as a sample:

https://example.lightbend.com/v1/download/play-samples-play-java-hello-world-tutorial

deploy example play application

Note: The provided package includes the sbt build tool, which is used to work with Play. If your project does not include this or a similar one, you’ll need to install it manually. For example, follow the steps from the official Play requirements page.

3. Our application works on the 9000 port, so it should be opened via the container firewall. Add a new inbound rule similar to the image below.

open port via container firewall

4. Now, you should allow access to your application’s 9000 port from outside the platform (i.e. via SLB) by adding an endpoint.

Note: This step should be skipped if your application is working over public IP.

open port via shared load balancer

5. Next, let’s access application via SSH (e.g. Web SSH) to manage it. Use the following command to disable default Play filter for allowed hosts:

1
echo play.filters.disabled+=play.filters.hosts.AllowedHostsFilter >> /opt/tomcat/webapps/ROOT/play-samples-play-java-hello-world-tutorial/conf/application.conf

disable default host filter for play

6. Execute the next two commands sequentially to move into the application’s directory and run it.

1
2
cd /opt/tomcat/webapps/ROOT/play-samples-play-java-hello-world-tutorial/  
bash ./sbt-dist/bin/sbt run

run play server with example application

7. Now, you can access your application in the browser using the Access URL of the endpoint you’ve created earlier.

endpoint to play application

In our case, the following page should be displayed:

play hello world application

That’s it! Your Play application is up and running, try the platform for yourself with a two-weeks trial at one of our partners.

What’s next?