Asimov Technologies
J2EE, JEE, PHP
Frank D. Martínez’s Blog
Software & Fun
Welcome to my technical blog. Here you can find my opinions and proposals over many software development things, mainly on open source projects.
EAC4J: Apache Commons Configuration via JNDI, and without dependencies!
With EAC4J (External Application Configuration For Java) you can externalize your application’s configuration with Apache Commons Configuration and get a Configuration Object via simple JNDI lookup. The isolated classloader decouples all needed classess and dependencies from your application except by one interface.
This is a simple Wrapper over Apache Commons Configuration, so you get all the power of it but decoupled from any additional dependency jar. And additionally you can easy reload the configuration without restart the server.
This was initially developed for Glassfish V2 and has been tested on it only.
Glassfish V2 integration:

1. Download the zip here.
2. Unzip it in some folder
3. There will be some files and a directory:
- eac4j-api.jar Contains shared interfaces and utilities
- eac4j-impl.jar Contains the Apache Commons Configuration Wrapper
- eac4j-demo.war Contains a web application demo.
- config.xml Contains a sample configuration file.
- app.properties Contains a sample configuration file.
- deps Contains all dependency jars
- all.src.zip Contains all source code.
4. Copy eac4j-api.jar into ${glassfish-domain-root}/lib/ext
5. Create folder ${glassfish-domain-root}/lib/eac4j
6. Copy eac4j-impl.jar into ${glassfish-domain-root}/lib/eac4j
7. Copy all files from deps to ${glassfish-domain-root}/lib/eac4j
8. Restart Glassfish
9. Copy config.xml and app.properties somewhere together (And remember where)
10. Open the Admin Console
11. Go to Resources - JNDI - Custom Resources - New
12. Fill the fields: (see the screenshot) IMPORTANT: Do not forget Property configFile

13. deploy eac4j-demo.war
14. Try http://localhost:8080/eac4j-demo/DemoServlet on your browser.
Replace ${glassfish-domain-root} for your glassfish domain root: for example /var/glassfish/domains/domain1
That’s all, see the source code of eac4j-demo (Just one class: DemoServlet.java) to see how to use it in your applications, the class JNDIServiceLocator.java is just a service locator.
See the Apache Commons Configuration documentation for further details.
If you have any problem, please tell me. If you want to test it in another Application Server, please share your experience.
Thanks,
Frank.
2 Responses to “EAC4J: Apache Commons Configuration via JNDI, and without dependencies!”
Leave a Reply
This site contains personal opinions about many things and does not intend to be normative in any aspect.
Java, J2EE, J2SE, JEE, Are trademarks of Sun Microsystems Inc.
I tried this with Glassfish version 2.1 and it worked well. One item of confusion for me is the notation used for the value of configFile. The value used the word path which I mistakenly read as a directory path but it really needs to include the config file name as well (which I should have deduced). To further the confusion, it still didn’t appear to work after I updated it to include the file and it took me a while to figure out that it was because the value was being cached in the servlet (or so I believe).
Anyway, thanks for this.
Bill
Great work!. Thank you!