Java EE application configuration using Aeonbits Owner

Every (almost) Java EE based application needs configuration — local, test or production — it does not matter. What matters — how easily this configuration solution is maintained and how easily the environment may be changed.

There are many ways to achieve the requirement, however in this blog I will cover one of possible CDI based configuration solutions — Owner by

Usually there are several stages when properties used in production:

  1. Hardcoded properties (usually done by novice programmers, otherwise I would treat such properties as constants);
  2. Properties file inside application war file (different properties configured during build time. It is not correct, because the same build cannot be deployed on different environments);
  3. Properties file stored in server file system (properties are independent from war and is environment specific).

Java EE lacks easy configuration functionality. There are many discussions related to this topic

  2. Storing and editing configuration for Java EE applications at Stack Overflow
  3. Configure Java EE applications or “Putting Bien into practice” and more others.

However they need custom actions to take into account:

  • You need to manage property injection yourself;
  • You need to use Spring framework, which has flexible configuration management mechanism. But do you need Spring only for property loading? I believe — no ☺


You need this environment setup in order to successfully complete the provided guide:


Defining an interface

 * Application configuration properties are defined here.
 * @author vicento.ramos
“file:/etc/”, “file:~/”, “classpath:/” })
public interface ApplicationConfig extends Accessible {
 int getInitialTimeout();

Creating a producer

 * Application scope based configuration file producer.
 * @author vicento.ramos
public class ApplicationConfigProducer {
 public ApplicationConfig produceSportsConfig() {
  return ConfigFactory.create(ApplicationConfig.class);

Creating a properties file file may be stored in one of these locations:

  • /etc/
  • /

And the content of the file:



 * Sample injection point of properties.
 * @author
public class SampleService {
 private ApplicationConfig applicationConfig;
 public void method() {
  System.out.println(String.format(“Config value: %d”, 


  • Multiple configuration locations — you may configure multiple lookup locations where configuration files may be fetched from;
  • CDI Injection — Java EE based CDI injection using @Named and @Inject annotation
  • Default values — you may configure default values easily using @DefaultValue
  • Hot reload — you may easily define the interval for properties hot reloading using @HotReload
  • And many more if required



Senior software engineer, software architect for java enterprise based solutions