Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4125860
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:55:29+00:00 2026-05-20T23:55:29+00:00

UPDATE : See my blog post on this topic about a year after this

  • 0

UPDATE: See my blog post on this topic about a year after this was written: http://blog.ringerc.id.au/2012/07/java-ee-7-needs-improvements-in-app.html

… for references to the Java EE 7 planning discussion on this topic.


I’ve mostly finished writing a small Java EE 6 application, and am in the process of replacing the hard-coded preferences with a proper dynamic configuration interface.

I’m not sure how – or, more specifically, where – to store settings. There must be some obvious, “standard” way to do this that’s expected to “just work” across various frameworks and containers, but for the life of me I cannot find it.

What I want is a simple way to load and store settings, one that works across different app servers and OSes, doesn’t require any confguration by the user, and actually works properly. The Java Preferences API would be ideal – but seems broken under Glassfish 3.1.

Options for storing configuration would theoretically include:

  1. Using context-parameters from the container environment
  2. Storing them using the Java Preferences API
  3. Reading/writing a properties file … somewhere
  4. Using JPA to store them in a JavaDB provided by the container
  5. Putting it in a properties file that’s loaded off the classpath
  6. Using system properties to set configuration options, or path to a .properties file

This would seem to be a basic requirement that’d be well catered for in an environment where the container supposedly provides you with all the core services you might need – but all these approaches have issues.

A bug in glassfish renders (1) unworkable, and in any case the Glassfish web admin user interface lacks any way to configure context parameters, so you have to use `asadmin’ and some less than lovely command line syntax to do it. Context parameters can only be accessed via the ServletContext – which isn’t accessible in a consistent way between frameworks like JSF2, JAX-RS, and raw servlets – but at least Seam Servlet handles that.

What appears to be another bug in glassfish was a library version conflict between the deployed app and Glassfish breaks (2). The preferences backend fails to flush preferences to disk, so the stored preferences data is lost when the application server is restarted. The Java Preferences API also seems to be considered a J2SE/desktop thing, despite its inclusion in the Java EE 6 specs.

(3) might work – but there’s no way to know where your app has read/write access on the file system and where it should look. You can’t make this configurable, as it becomes a chicken-and-egg problem then. Various platform-specific guesses could be applied, but would break in the presence of a SecurityManager.

(4) would work, but it’s nuking a fly. It requires that a JavaDB service be running and forces the user to make sure the JDBC and pool resources in the app server are configured properly. It’s big and complicated for a simple job, and entity modelling isn’t a lovely fit for preferences storage anyway, as it’ll mostly land up being key/value structured.

(5) would work, but requires users to know where to put the config file where it’ll be found under various different app servers. It also makes it hard for the app to provide any kind of configuration UI because it can’t necessarily find the local path to the config file or open it for writing, especially in the presence of a SecurityManager.

(6) would also work, but forces the user to configure the configuration system before they can configure the application. Needless to say, that doesn’t excite me, given how relatively complicated deploying the app and creating the resources already is for users who don’t already know Glassfish/EE.

So … how are you handling configuration and storage of options? Have you found a way that lets you “just do it” without the user having to configure anything to allow your app to store its configuration?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T23:55:30+00:00Added an answer on May 20, 2026 at 11:55 pm

    The problem with the preferences API was caused by the inclusion of jaxb and stax implementation jars on in the application’s war, pulled in by jersey-json . With these excluded (as they’re provided by the app server anyway) the preferences API resumed functioning correctly.

    It looks like the prefs API with custom UI for setup appears to be the best way to go.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Update: This turned into a blog post, with updated links and code, over at
Update: this question, including the title, was rephrased, see history for details I know
Duplicate of this question . update - This is not an exact duplicate. See
This question is about 64-bit Java apps in general, although I came upon it
I see that EF can update a model based on an existing database schema.
Update: Solved, with code I got it working, see my answer below for the
Update: Check out this follow-up question: Gem Update on Windows - is it broken?
Update: Now that it's 2016 I'd use PowerShell for this unless there's a really
Update and Solution I finally got everything working after 1. Uninstalling everything ruby-related in
Here's some code I saw once. Can you see what's wrong with it? [updated]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.