Locate avaje.properties

Note that this changed with Version 0.9.2.

Options for finding/loading avaje.properties

There are 5 ways in which the avaje.properties file can be found.

  • by setting an Environment Variable AVAJE_PROPS_FILE
  • by Setting a Java System property avaje.props.file
  • found in the WEB-INF directory for a Servlet Container (Tomcat/Jetty etc)
  • found in the current working directory
  • found in the classpath

Servlet Container (Tomcat/Jetty etc)

Put the avaje.properties file in the WEB-INF directory and it should automatically be found.

Standalone "public static void main(String[] args)"

Put the avaje.properties file in the working directory or classpath.

Servlet Container AND Standalone

Note that I expect this to be the most common configuration for using Ebean.

You are developing a web application using Ebean, and sometimes want to write code to unit test persistence logic outside of the servlet Container (without running Tomcat/Jetty etc).

That is, even though you are building a web application you want to sometimes write a class with a "static void main(String[] args)" method to test some Ebean behaviour (unit test some persistence logic).

Put avaje.properties into the WEB-INF directory
For when run in the servlet container
Put a second avaje.properties into the working directory
Initialise/set properties normally set by the servlet container such as ${catalina.base}. Load the 'real' properties from the WEB-INF directory

You can see an example of the 2 avaje.properties in examples/bugProduct.

Programmatically Configure

Ebean uses com.avaje.lib.SystemProperties to read all its configuration information. If you want you can programmatically set the configuration via SystemProperties.setProperty().

However, you must do this BEFORE Ebean is initialised.

If you want a 100% programmatic configuration without any avaje.properties file and this is insufficient information then just let me know - thanks.

Introduction User Guide (pdf) Install/Configure Public JavaDoc Whitepapers
General Database Specific Byte Code Deployment Annotations Features
Top Bugs Top Enhancements
woResponse