static final constants in local bean interface


EJB design: static final constants in local bean interface

  1. static final constants in local bean interface (2 messages)

    I've got a question about constants in a local interface of a bean that come from evaluation an expression. If I evaluate the expression ConfigurationManager.getInstance().getProperty("welcomeSMSTriggerEnabled"); during debugging then I get the string ENABLED. If I evaluate the constant variable using the call SMSMsgHandlerLocal.WELCOME_SMS_TRIGGER_ENABLED on the local interface, then I get the null value.

    Can anyone help me with this "problem"? Does it also not work in a normal Java environment without J2EE?

     * @author Mark Noten <mark dot noten dot ext at siemens dot com>
     * (c) 2005 SIEMENS AG

    import ...

    public interface SMSMsgHandlerLocal extends EJBLocalObject {

        public static final String WELCOME_SMS_TRIGGER_ENABLED = ConfigurationManager

        public int createWelcomeMessage(String msisdn, String password)
                throws ProtocolSenderException;

    Best regards,

  2. Are you sure ConfigurationManager.getInstance() returns something that's ready to go the very first time it might be called when SMSMsgHandlerLocal has its statics initialized?

    Have you checked for console output? If an exception is thrown while initializing statics, you'll probably see a stack trace in the console.
  3. Here's the code of the ConfigurationManager class. When the getInstance method is called, it will return an unique instance or create a new. No exceptions are thrown. I just don't get it.

    public class ConfigurationManager {

        private static ConfigurationManager instance = null;

        private static Properties imcProperties = null;

        // TODO Get the config files URL from a system environment variable
        private static final String CONFIG_FILES_URL = "config/MAGELLAN/";

        private static Logger logger = Logger.getLogger(ConfigurationManager.class);

        private ConfigurationManager() {

        public static ConfigurationManager getInstance() {
            if (instance == null) {
                instance = new ConfigurationManager();
            return instance;

        public String getProperty(String key) {
            if (!imcProperties.containsKey(key)) {
                return null;
            } else {
                return imcProperties.getProperty(key).trim();

        private static void init() {
            imcProperties = new Properties();
            InputStream inputStream = ConfigurationManager.class.getClassLoader()
            Properties configFilesProperties = new Properties();
            try {
                Enumeration configFilesKeys = configFilesProperties.keys();
                while (configFilesKeys.hasMoreElements()) {
                    String propertiesFileURLKey = (String) configFilesKeys
                    String propertiesFileURL = configFilesProperties
            } catch (IOException exc) {
                        .error("Could not load properties file from imc/config/IMC210/");

        private static void readPropertiesFromFile(String fileURL) {
            InputStream inputStream = ConfigurationManager.class.getClassLoader()
            Properties properties = new Properties();
            try {
            } catch (IOException exc) {
                        .error("Could not load properties file from " + fileURL
                                + ".");