0 Replies Latest reply on Mar 13, 2013 2:00 PM by Betto McRose Gamarra

    System.getProperty("jboss.server.config.dir") returns null on linux

    Betto McRose Gamarra Newbie

      Hi all

       

      I'm facing this problem, I'm trying to get the server config url but I'm getting null values

       

      is it a permission problem ?

      my linux is crunchbang 10

       

       

       

          String filepath = System.getProperty("jboss.server.config.dir") +
                              File.separator + cfgFileName;
         
          PTIProperties parameteres = new PTIProperties();
          parameteres.load(new FileInputStream(filepath));

       

       

      I check every possibility but no success at all

       

      /**

      *

      */

      package py.com.icarusdb.loadconfig.test;

       

      import java.io.FileInputStream;

      import java.io.FileNotFoundException;

      import java.io.IOException;

      import java.util.Iterator;

      import java.util.Map;

      import java.util.Properties;

       

      import py.com.icarusdb.util.GlobalParameters;

      import py.com.icarusdb.util.PTIProperties;

      import py.com.icarusdb.util.UriBuilder;

       

      /**

      * @author mcrose

      *

      */

      public class loadConfig

      {

       

          private static final String JBOSS_SERVER_BASE_DIR = "jboss.server.config.url";

          private static String CFG_FILE_NAME = "auth-rest.cfg.properties";

       

          /**

           * @param args

           */

          public static void main(String[] args)

          {

              String filepath = System.getenv(JBOSS_SERVER_BASE_DIR);

             

              if(filepath == null || filepath.isEmpty())

              {

                  Map<String, String> envvarz = System.getenv();

                 

                  System.out.println("scanning System.getevn()...");

                 

                  Iterator<String> iterator = envvarz.keySet().iterator();

                  while (iterator.hasNext())

                  {

                      String key = iterator.next();

                      if(key.toLowerCase().contains("jboss")) {

                          System.out.println("key: " + key + "->" + envvarz.get(key));

                      }

                  }

                 

                  if(envvarz.containsKey(JBOSS_SERVER_BASE_DIR)) {

                      filepath = envvarz.get(JBOSS_SERVER_BASE_DIR);

                  }

              }

       

              if(filepath == null || filepath.isEmpty()) {

                  filepath = System.getProperty(JBOSS_SERVER_BASE_DIR);

              }

             

              if(filepath == null || filepath.isEmpty())

              {

                  System.out.println("\nscanning System.getProperties()...");

                 

                  Properties sysprops = System.getProperties();

                  Iterator<Object> iterator = sysprops.keySet().iterator();

                  while (iterator.hasNext())

                  {

                      Object key = iterator.next();

                      if(key.toString().toLowerCase().contains("jboss")) {

                          System.out.println("key: " + key + "->" + sysprops.get(key));

                      }

                  }

                 

                  if(sysprops.containsKey(JBOSS_SERVER_BASE_DIR)) {

                      filepath = (String) sysprops.get(JBOSS_SERVER_BASE_DIR);

                  }

                 

              }

             

              if(filepath != null && !filepath.isEmpty())

              {

                  System.out.println("filepath: " + filepath);

                 

                  filepath += CFG_FILE_NAME + GlobalParameters.SERVER_CONFIG_FILE_FOLDER;

                 

                  System.out.println("full-filepath: " + filepath);

                 

                  PTIProperties parameteres = new PTIProperties();

                  try

                  {

                      parameteres.load(new FileInputStream(filepath));

                  }

                  catch (FileNotFoundException e)

                  {

                      e.printStackTrace();

                  }

                  catch (IOException e)

                  {

                      e.printStackTrace();

                  }

                 

                 

                  String uri = UriBuilder.buildLoginUri(parameteres);

                  System.out.println("uri: " + uri);

              }

             

             

       

          }

       

      }