5 Replies Latest reply on Apr 20, 2007 12:07 PM by manik

    config loading issue with 2.0.0.BETA2

      I'm trying to get an instance of Cache using the following code:

      CacheFactory<String, String> factory = DefaultCacheFactory.getInstance();
      Cache<String, String> _cache = factory.createCache( _configFile, false );


      I keep getting the following error, no matter what file path syntax I use:

      org.jboss.cache.config.ConfigurationException: Input stream for configuration xml is null!
       at org.jboss.cache.factories.XmlConfigurationParser.parseStream(XmlConfigurationParser.java:72)
       at org.jboss.cache.factories.XmlConfigurationParser.parseFile(XmlConfigurationParser.java:63)
       at org.jboss.cache.DefaultCacheFactory.createCache(DefaultCacheFactory.java:57)


      I don't want my config file to be compiled into the jar, I want to use an external file. What am I doing wrong? Any ideas would be appreciated.

      The 1.4.1 version, PropertyConfigurator.configure, would try loading the given file path using a FileInputStream if the class loader couldn't load the file from the classpath. I'm confused why that was not carried over to 2.0 because it seems that would solve my problem.

        • 1. Re: config loading issue with 2.0.0.BETA2
          manik

          You're right, it should have been carried over. See JBCACHE-1021.

          If you want to patch 2.0.0.BETA2, the files changed are:

          org.jboss.cache.CacheFactory
          org.jboss.cache.factories.XmlConfigurationParser
          


          You can grab them from CVS HEAD.

          Thanks for letting me know about this. :-)


          • 2. Re: config loading issue with 2.0.0.BETA2

            Well, thanks for fixing it. I've been told we can't change the JBoss code, for license reasons (whatever that means), so I'll just have to figure out some kind of hack until another release comes out.

            Thanks for the quick response.

            • 3. Re: config loading issue with 2.0.0.BETA2
              manik

              As a workaround, just put your root directory in your classpath and it should get picked up using the class loader. Not clean in any way, but it *is* a temporary workaround, after all. :-)

              • 4. Re: config loading issue with 2.0.0.BETA2
                fredrikj

                If it helps, I extended DefaultCacheFactory and added my own little factory method that accepts an input stream.

                The method looks like:

                public Cache createCache(InputStream is, boolean start) throws ConfigurationException {
                 XmlConfigurationParser parser = new XmlConfigurationParser();
                 Configuration c = parser.parseStream(is);
                 return createCache(c, start);
                }
                


                Of course, it should be possible to _not_ extend the factory and create a cache in a similar manner.

                • 5. Re: config loading issue with 2.0.0.BETA2
                  manik

                  There still is time to add another factory method - why don't you send me a patch to DefaultCacheFactory? It would make it into the next rel.