Fetching contributors…
Cannot retrieve contributors at this time
84 lines (58 sloc) 4.34 KB
title: Java Buildpack
owner: Java
You can use use the Java buildpack with apps written in Grails, Play, Spring, or any other JVM-based language or framework.
See the following topics for more information:
* <a href="./java-tips.html" class="subnav">Tips for Java Developers</a>
* <a href="./getting-started-deploying-apps/index.html" class="subnav">Getting Started Deploying Apps</a>
* <a href="./configuring-service-connections/index.html" class="subnav">Configuring Service Connections</a>
* <a href="./sts.html" class="subnav">Cloud Foundry Eclipse Plugin</a>
* <a href="./java-client.html" class="subnav">Cloud Foundry Java Client Library</a>
See the [Java Buildpack Release Notes]( for information about specific versions.
You can find the source for the Java buildpack in the [Java buildpack repository]( on GitHub:
## <a id='logging'></a> Buildpack and Application Logging ##
The Java buildpack only runs during the staging process, and therefore only logs
staging information such as the downloaded components, configuration data, and work performed on your application by the buildpack.
The Java buildpack source documentation states the following:
* The Java buildpack logs all messages, regardless of severity, to
`APP-DIRECTORY/.java-buildpack.log`. The buildpack also logs messages to `$stderr`, filtered by a configured severity level.
* If the buildpack fails with an exception, the exception message is logged with
a log level of `ERROR`. The exception stack trace is logged with a log
level of `DEBUG`. This prevents users from seeing stack traces by default.
Once staging completes, the buildpack stops logging. The Loggregator handles application logging.
Your application must write to STDOUT or STDERR for its logs to be included in
the Loggregator stream. For more information, see the [Application Logging in Cloud Foundry](../../devguide/deploy-apps/streaming-logs.html) topic.
## <a id='bosh-trusted-cert'></a> BOSH Custom Trusted Certificate Support
Versions 3.7 and later of the Java buildpack support BOSH-configured custom trusted certificates. For more information, see [Configuring Trusted Certificates]( in the BOSH documentation.
The Java buildpack pulls the contents of `/etc/ssl/certs/ca-certificates.crt` and `$CF_INSTANCE_CERT/$CF_INSTANCE_KEY` by default.
The log output for Diego Instance Identity-based `KeyStore` appears as follows:
Adding System Key Manager
Adding Key Manager for /etc/cf-instance-credentials/instance.key and /etc/cf-instance-credentials/instance.crt
Start watching /etc/cf-instance-credentials/instance.crt
Start watching /etc/cf-instance-credentials/instance.key
Initialized KeyManager for /etc/cf-instance-credentials/instance.key and /etc/cf-instance-credentials/instance.crt
The log output for Diego Trusted Certificate-based `TrustStore` appears as follows:
Adding System Trust Manager
Adding TrustManager for /etc/ssl/certs/ca-certificates.crt
Start watching /etc/ssl/certs/ca-certificates.crt
Initialized TrustManager for /etc/ssl/certs/ca-certificates.crt
## <a id='memory-constraints'></a> Memory Constraints in Java Buildpack 4.0
The memory calculator in Java buildpack 4.0 accounts for the following memory regions:
<li><code>-Xmx</code>: Heap</li>
<li><code>-XX:MaxMetaspaceSize</code>: Metaspace</li>
<li><code>-Xss</code>: Thread Stacks</li>
<li><code>-XX:MaxDirectMemorySize</code>: Direct Memory</li>
<li><code>-XX:ReservedCodeCacheSize</code>: Code Cache</li>
<li><code>-XX:CompressedClassSpaceSize</code>: Compressed Class Space</li>
Applications which previously ran in 512&nbsp;MB or smaller containers may no longer be able to. Most applications will run if they use the Cloud Foundry default container size of 1&nbsp;G without any modifications. However, you can configure those memory regions directly as needed.
The Java buildpack optimizes for all non-heap memory regions first and leaves the remainder for the heap.
The Java buildpack prints a histogram of the heap to the logs when the JVM encounters a terminal failure.
The Cloud Foundry default Java buildpack is currently 3.x to allows time for apps to be upgrade to 4.x.
For more information, see [Java buildpack 4.0](