Getting/Setting in J2EE


EJB programming & troubleshooting: Getting/Setting in J2EE

  1. Getting/Setting in J2EE (3 messages)

      We are running into some problems with our product.
     We use System properties to configure several of
      our libraries, as do many standard java packages.
      We are deploying on weblogic 6.0 and finding that
      there isn't a good way to set System properties
      ( other than a -D on the command line ). Was this
      done for a reason ??? Are accessing System properties
      considered "bad form" for J2EE applications ??
      Why exactly ??? It's not mentioned in the EJB spec
      that it shouldn't be done.

      --- jerome
  2. Have you tried simply listing them in I rather thought that worked, but then I never played with it too much.

    The other solution, which is more effective, is to use a WebLogic startup class to set the properties, by reading them from a properties file. That's about 10 lines of code and a bit cleaner.

    In any case, you are better off not using system properties to drive things. They (by definition) apply to the whole VM which can be painful at times (at least it has been for me.)




  3.  Thanks for the advice ...

      The problem is that there doesn't seem to
      be a file anymore, just
      a config.xml , and there is no place to set
       system properties that we can find.

     My question is more a philosophical/design issue;
      when should you use System properties, when JNDI,
      when some other mechanism for J2EE applications.

      We used System properties mostly for Singleton/static
      configuration ( where is the resource file, what
      implementing class do we use for an interface, etc.)
      This seems reasonable to me, because they need to be set
      regardless of the envirnoment ( J2EE or non-J2EE )

      Others may argue that System properties should never be
      used for configuration, since your application may be
      sharing a VM with other applications, and may squash/be
     squashed by applications. I would think this could be
      avoided by using a namespace ( like <company>.<subsystem>.<property> ) which seems to be the
      de facto standard (, )
      I wanted to ask the J2EE community their opinion on this.
  4. My own opinion is that they should not be used, as it has two definite consequences.

    1) It applies to the whole VM (unless you make it ClassLoader specific.)
    2) It leads to lots of scripts with -D parameters in them, which is not pretty and prone to error. Configuration belongs in a configuration repository, not in startup scripts.

    Didn't realize you were using 6.0, sorry about that. There is no, but there is probably a way to set system properties in there.