
Leading the Way: Payara Platform Community 7 Beta Now Fully Jakarta EE 11 Certified
We’re excited to announce that Payara Platform Community 7 Beta application server is now fully certified as Jakarta EE 11 […]
Welcome to another episode of Nugget Friday, where we bring you bite-sized insights to make your development journey smoother and more efficient! This week, we’re tackling a common challenge: how to dynamically configure your Payara Micro application after it’s already deployed in a production environment.
Imagine you have a Payara Micro application deployed in a production environment. You need to make dynamic configuration changes after the server starts up, such as adjusting logging levels, enabling security, or setting environment-specific properties. Manually connecting to the server and executing asadmin commands each time is not only cumbersome but also prone to errors, especially in a high-availability setup with multiple instances.
Payara Micro offers a powerful solution to this challenge with pre-boot and post-boot scripts. These scripts allow you to automate configuration tasks at different stages of the server lifecycle, simplifying your deployment process and reducing manual intervention.
If needed, you can create a pre-boot-commands.txt file containing asadmin commands to be executed before the server starts. These commands are typically used for setting up essential resources or modifying core configurations.
Package with Payara Micro: Bundle your pre-boot script (if applicable) and your application into an Uber JAR using the –outputUberJAR option:
java -jar payara-micro.jar --prebootcommandfile pre-boot-commands.txt --outputUberJAR myapp.jar
Create a post-boot-commands.txt file with asadmin commands to be executed after the server has started. This is where you can fine-tune your application’s settings dynamically:
# Set logging level for a specific logger
set-log-levels com.example.myapp.logger=FINEST
# Enable security
set configs.config.server-config.security-service.auth-realm.file.file=${com.sun.aas.instanceRoot}/config/keyfile
# Set environment-specific property
create-system-properties environment=production
You can package your post-boot files with the same command as the preboot command, only changing to –prebootcommandfile to –prebootcommandfile.
When you deploy myapp.jar, Payara Micro will first execute the pre-boot script (if present) and then, after the server starts, the post-boot script. Your application will be configured automatically without manual intervention.
There is also a –postdeploycommandfile for executing commands after all deployments have completed.
Payara Micro’s pre-boot, post-boot and post-deployment scripts offer a flexible way to manage your application’s configuration. By automating these tasks, you can simplify your deployment process, enhance reliability and focus on delivering value to your users. Take a look at the Payara Micro docs on the boot scripts for more usage examples and download Payara Micro here.
Happy Nugget Friday and Happy Coding!
Share:
We’re excited to announce that Payara Platform Community 7 Beta application server is now fully certified as Jakarta EE 11 […]
Welcome aboard the August 2025 issue of The Payara Monthly Catch! With summer in full swing, things may have felt […]
Enterprise Java applications power global commerce, healthcare, government and countless other industries. These systems must be scalable, secure and […]