3 Replies Latest reply: Sep 28, 2007 5:24 AM by 807605 RSS

    Error reading XML properties file on Linux

    807605
      Hi guys

      I'm getting a bit desperate here, i'm developing an application to run on tomcat, that uses Properties files in XML to save some configuration.

      Here's my file:

      <?xml version="1.0" encoding="UTF-8" standalone="no"?>
      <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">

      <properties>

      <entry key="company.name">My Company</entry>

      <entry key="application.name">My Application</entry>
      <entry key="application.version">1.0</entry>
      <entry key="application.classes.file">classes.cfg.xml</entry>

      <entry key="datatable.rowsPerPage">15</entry>

      </properties>


      Now the wierd part... On my developing machine (Windows) everything works fine, and i deploy it on a server (Fedora + tomcat 6) the application can't read the file correctly, it reads the keys but not the values.

      Here's the code:

      public void loadFromFile(String filename)
      throws IOException {

      Properties properties = new Properties();

      InputStream stream = new FileInputStream(((ServletContext)FacesContext.getCurrentInstance().getExternalContext().getContext()).getRealPath(filename));

      try {

      properties.loadFromXML(stream);
      } catch (IOException ex) {
      throw ex;
      }

      this.props = properties;
      this.filename = filename;

      stream.close();
      }



      Thanks in advance..
        • 1. Re: Error reading XML properties file on Linux
          469223
          How are you establishing that it is actually reading the keys? Have you iterated over the returnvalue of propertyNames()? By default, getProperty(String) will return null if it can't find the entry, not throw an error. Is it possible that the file is not being read and you have handled the exception somewhere so you don't get an error output?

          My guess is that this would be some kind of path or permissions issue, but I would expect this to throw a FileNotFoundException. Any rational explanation for this behavior that I can come up with would throw an exception somewhere so I suspect it is either getting swallowed or there is an entry in the log files of your server for it.
          • 2. Re: Error reading XML properties file on Linux
            807605
            Well i'm using getProperty(...), but if java could't read the file, the keys weren't read.

            But I can get the keys, just not the values. On tomcat logs until the moment i can't get any output, no IOException is throw at loadFromXml.
            • 3. Re: Error reading XML properties file on Linux
              807605
              Some update on this problem, when I try to access the same file but on the plain text format, iot works fine.