5 Replies Latest reply on Oct 31, 2005 6:38 AM by Manik Surtani

    treecache.xml file not found

    Rachna Aggarwal Newbie


      I am using JBoss 3.2.6 with hibernate 2.0 in my application. I wanted to use caching in my application through TreeCache and so I specified in my hibernate.properties file: hibernate.cache.provider_class=net.sf.hibernate.cache.TreeCacheProvider. But as soon as the server starts and it tries to build the sessionfactory on the configuration specified by the hibernate.properties file, when it tries to put a persistent read-only object into the cache for the first time, it throws the following exception:

      java.io.FileNotFoundException: treecache.xml (The system cannot find the file specified)
      11:23:33,030 INFO [STDOUT] at java.io.FileInputStream.open(Native Method)
      11:23:33,030 INFO [STDOUT] at java.io.FileInputStream.(FileInputStream.java:106)
      11:23:33,030 INFO [STDOUT] at java.io.FileInputStream.(FileInputStream.java:66)
      11:23:33,030 INFO [STDOUT] at org.jboss.cache.PropertyConfigurator.configure(PropertyConfigurator.java:154)
      11:23:33,030 INFO [STDOUT] at net.sf.hibernate.cache.TreeCache.(TreeCache.java:42)
      11:23:33,030 INFO [STDOUT] at net.sf.hibernate.cache.TreeCacheProvider.buildCache(TreeCacheProvider.java:14)
      11:23:33,030 INFO [STDOUT] at net.sf.hibernate.cfg.Configuration.configureCaches(Configuration.java:1107)
      11:23:33,030 INFO [STDOUT] at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:767)

      I found that when TreeCache is instantiated it tries to load some properties form treecache.xml file which is not there so it gave me this exception. Then I downloaded some treecache.xml file from the net and added it manually to hibernate.jar but still the problem persists.

      Can somebody please help me out here?


        • 1. Re: treecache.xml file not found
          Andy W. Clements Newbie

          have you tried just placing the treecache.xml file in your deploy directory?

          • 2. Re: treecache.xml file not found
            Rachna Aggarwal Newbie

            Yes, I tried placing it in deploy directory but it didn't work.

            Actually, I was placing the file in the hibernate.jar at the same package level as the TreeCache class which was calling getResourceAsStream on the file and it was not able to locate the file.

            But when I placed the file at the parent level , the file was found and the chaching worked.

            But I am not able to understand as to why hibernate.jar did not include treecache.xml file if it is hardcodedly asked in the code???? Here is the code from net.sf.hibernate.cache.TreeCache which requires this treecache.ml file:

            public TreeCache(String regionName, Properties props)
            throws CacheException
            this.regionName = '/' + regionName.replace('.', '/');
            if(cache == null)
            cache = new org.jboss.cache.TreeCache();
            PropertyConfigurator config = new PropertyConfigurator();
            config.configure(cache, "treecache.xml");
            net.sf.hibernate.transaction.TransactionManagerLookup tml = TransactionManagerLookupFactory.getTransactionManagerLookup(props);
            if(tml != null)
            cache.setTransactionManagerLookup(new TransactionManagerLookupAdaptor(tml, props));
            catch(Exception e)
            throw new CacheException(e);

            • 3. Re: treecache.xml file not found
              Steve Ebersole Apprentice


              But when I placed the file at the parent level , the file was found and the chaching worked.

              Hibernate simply attempts to locate a file named treecache.xml as a classpath resource. So of course it needs to be at the root of a jar file if thats how you choose to deploy it. (yes, this is all covered in the Hibernate docs).

              But I am not able to understand as to why hibernate.jar did not include treecache.xml file if it is hardcodedly asked in the code????

              Yes, of course it requires a TreeCache configuration file. Is it just supposed to magically build and configure a TreeCache instance by itself? Include a treecache.xml in the hibernate distribution???!?!?!!! Are you serious?

              • 4. Re: treecache.xml file not found
                wpereira Newbie

                Since hibernate used to work without this file I don't think is stupid to say that the file should be there somewhere.
                I found almost no explanation on the hibernate documentation about this file and had to figure it out how to configure.
                This is a issue for dummies and shouldn't be answered like that.

                • 5. Re: treecache.xml file not found
                  Manik Surtani Master

                  Of course Hibernate would work without this file - IF you don't configure it to use TreeCache!!

                  You always needed treecache.xml in your classpath if you planned to use TreeCache.