War/Ear
Overview
Clever Cloud allows you to run WAR or EAR applications. You can deploy these projects without changing your code. We just need a configuration file with your targeted container.
In JEE , application modules are packaged as EAR and WAR based on their purpose.
WAR : Web modules which contains Servlet class files, JSP FIles, supporting files, GIF and HTML files are packaged as JAR file with .war extension.
EAR :
*.warand*.jarfiles are packaged as JAR file with.earextension and deployed into Application Server. EAR file contains configuration such as application security role mapping, EJB reference mapping and context root URL mapping of web modules.
Note: Clever Cloud configures your container to listen on 0.0.0.0:8080, or on port 9000 with Request Flow: you have nothing to set. Learn more about the port of your application.
Available Java versions
Set the environment variable CC_JAVA_VERSION to the version you want.
We follow the official Java roadmap by supporting both LTS and latest non-LTS versions.
We are using OpenJDK distribution for mentioned Java versions.
Every non-LTS versions where Premier support ends will be removed without warning as you should be able to switch to the next available non-LTS version without any trouble.
| Default Version | Accepted Versions |
|---|---|
21 | 25 |
24 (EOL) | |
23 (EOL) | |
21 | |
17 | |
11 | |
8 | |
7 (EOL) | |
graalvm-ce |
The end-of-life (EOL) versions are marked as such.
(graalvm-ce for GraalVM 21.0.0.2, based on OpenJDK 11.0)
Configure your Java application
clevercloud/war.json file in your application repository.Full configuration example
Here’s what your configuration file can look like:
{
"build": {
"type": "maven",
"goal": "package"
},
"deploy": {
"container": "TOMCAT10",
"war": [
{
"file": "target/my-app-1.0-SNAPSHOT.war",
"context": "/app1",
"checkMe": "/app1/ping"
},
{
"file": "my-second-app.war",
"context": "/app2",
"checkMe": "/app2/web/foobar"
}
]
}
}Breaking down the configuration
Requirements
Here are the mandatory fields:
{
"deploy": {
"container":"<string>",
"war": [
{
"file": "<string>",
"context": "/<string>",
"checkMe": "/<string>"
}
]
}
}| Usage | Field | Description |
|---|---|---|
| Required | container | Name of the container to use. Should contain one of the values inside parentheses in the containers table (uppercase). |
| Required | file | Should contain the path of the war/ear file relative to your application root. |
| Optional | context | - Must start with a slash (/), can be “/” - Defines the base path you want your app to be under. If your app has a /foobar endpoint, it will be available under the /{my-context}/foobar path.- Not needed for an ear file.- The default value for a war is the name of the war without the extensions: helloworld-1.0.war will be deployed under the /helloworld-1.0 context. |
| Optional | checkMe | - This field is recommended. - A path to GET in order to test if the application is really running. - By default we will consider that the application is up if the container is up. - With this option, we will try to GET /{checkMe} for each one of your wars and consider the app down until every single checkMe path that replies a 200. |
Let Clever Cloud build your application
The mandatory part alone is enough… if you directly push a dry war file to deploy. You might want to just push your code to Clever Cloud and let us build the app and generate the war.
That you can do, by setting the “build” field object in the war.json file:
{
"build": {
"type": "<string>",
"goal": "<string>"
}
}| Usage | Field | Description |
|---|---|---|
| Required | type | - The tool you want to use to build your app. - Can be “maven”, “gradle”, “sbt” or “ant” |
| Required | goal | - The goal you want the tool to execute. - Basically, for maven, you want to put “package” in here. |
Monitor your application with New Relic
You can use New Relic to monitor your application on Clever Cloud.
Please refer to our New Relic documentation to configure it for your application.
Available containers for war.json
Here’s the list of the configuration values for the “container” field in war.json (with End Of Life versions tagged as EOL):
| Value | Description | EOL |
|---|---|---|
| JETTY9 | Use Jetty servlet container 9.x (see https://jetty.org/download.html#version-history) | EOL |
| JETTY11 | Use Jetty servlet container 11.x (see https://jetty.org/download.html#version-history) | EOL |
| PAYARA5 | Use Payara servlet container 5.x (see https://www.payara.fish/) | EOL |
| PAYARA6 | Use Payara servlet container 6.x (see https://www.payara.fish/) | EOL |
| TOMCAT8 | Use Tomcat servlet container 8.x (see https://tomcat.apache.org/) | EOL |
| TOMCAT9 | Use Tomcat servlet container 9.x (see https://tomcat.apache.org/) | |
| TOMCAT10 | Use Tomcat servlet container 10.x (see https://tomcat.apache.org/) | |
| WILDFLY9 | Use Wildfly servlet container 9.x (see https://wildfly.org/) | EOL |
| WILDFLY27 | Use Wildfly servlet container 27.x (see https://wildfly.org/) | EOL |
| WILDFLY33 | Use Wildfly servlet container 33.x (see https://wildfly.org/) | EOL |
Environment injection
Clever Cloud exposes environment variables defined for your application alongside those provided by linked add-ons. Read a standard variable such as MY_VARIABLE from the process environment with:
String value = System.getenv("MY_VARIABLE");Java system properties
By default, Clever Cloud also passes variables to the generated launch command as Java system properties using -D options. When this command runs your application in the same JVM, retrieve a property with System.getProperty("MY_VARIABLE").
Variable names containing a dot (.) or a dash (-) are not exported to the process environment. The generated launch command only receives them as Java system properties. For example, if you define my.app.config=production for your application, Clever Cloud adds -Dmy.app.config=production to the generated launch command.
A Maven or Gradle deployment goal can start the application in another JVM. In this case, forwarding system properties depends on the plugin or task configuration. When the property reaches the application JVM, retrieve its value with:
String value = System.getProperty("my.app.config"); // returns "production"This mechanism can configure frameworks such as Spring Boot or Quarkus without modifying configuration files. Prefer standard environment variable names for portable application configuration.
Setting CC_RUN_COMMAND replaces the generated launch command, so Clever Cloud no longer adds these -D options automatically. With a custom run command, use standard environment variable names and map them in your application configuration.
Custom run command
If you need to run a custom command
you can specify it through the CC_RUN_COMMAND environment variable.
This will override the default way of running your application.
Example:
CC_RUN_COMMAND="java -jar somefile.jar <options>"