4 Replies Latest reply: Feb 13, 2013 1:52 PM by 909220 RSS

    AbstractCacheLoader does not get initialized

    909220
      When the instance of the cache is gotten and we try to do a get, the CacheLoader load method does not get invoked.

      this is the invocation we are currently doing:
      NamedCache TestCache = CacheFactory.getCache("TestFixed");
      TestTables message = (TestTables)TestCache.get(key);

      we always get null as a result. The CacheLoader constructor doesnt get invoked, neither the load method.

      this is the implementation:

      public class TestFixedCacheLoader extends AbstractCacheLoader {
      private static Logger logger = Logger.getLogger("oracle.soa.Logger");

      public TestFixedCacheLoader() {
      super();
      logger.log(Level.INFO, "START TestFixedCacheLoader - INITIALIZED ");
      }

      @Override
      public Object load(Object oKey) {
      logger.log(Level.INFO, "START TestFixedCacheLoader.load "+oKey);
      TestTablesFacade Tests = new TestTablesFacade();
      return Tests.getTestTablesFixedFind((TestTablesID)oKey);
      }


      this is the cache.xml.


      <?xml version="1.0"?>
      <!DOCTYPE cache-config SYSTEM "cache-config.dtd">
      <cache-config>
      <caching-scheme-mapping>
      <cache-mapping>
      <cache-name>TestDefault</cache-name>
      <scheme-name>Test-replicated</scheme-name>
      </cache-mapping>
      <cache-mapping>
      <cache-name>TestFixed</cache-name>
      <scheme-name>Test-distributed</scheme-name>
      </cache-mapping>
      </caching-scheme-mapping>
      <caching-schemes>
      <replicated-scheme>
      <scheme-name>Test-replicated</scheme-name>
      <backing-map-scheme>
      <local-scheme/>
      </backing-map-scheme>
      <autostart>true</autostart>
      </replicated-scheme>
      <distributed-scheme>
      <scheme-name>Test-distributed</scheme-name>
      <service-name>TestDistributedCache</service-name>
      <thread-count>5</thread-count>
      <backup-count>1</backup-count>
      <backing-map-scheme>
      <read-write-backing-map-scheme>
      <internal-cache-scheme>
      <local-scheme>
      <eviction-policy>LRU</eviction-policy>
      <high-units>1000</high-units>
      <expiry-delay>10m</expiry-delay>
      </local-scheme>
      </internal-cache-scheme>
      <cachestore-scheme>
      <class-scheme>
      <class-name>com.company.Test.coherence.TestFixedCacheLoader</class-name>
      <init-params>
      <init-param>
      <param-type>String</param-type>
      <param-value>{cache-name}</param-value>
      </init-param>
      </init-params>
      </class-scheme>
      </cachestore-scheme>
      </read-write-backing-map-scheme>
      </backing-map-scheme>
      <autostart>true</autostart>
      </distributed-scheme>
      </caching-schemes>
      </cache-config>
        • 1. Re: AbstractCacheLoader does not get initialized
          Jonathan.Knight
          Hi,

          Do you have errors in your server log saying that it cannot create your cache store class?

          One problem might be that the code you have shown for the cache store has only has this single constructor...
          public TestFixedCacheLoader() {
              super();
              logger.log(Level.INFO, "START TestFixedCacheLoader - INITIALIZED "); 
          }
          whereas the configuration is like this...
          <cachestore-scheme>
            <class-scheme>
              <class-name>com.company.Test.coherence.TestFixedCacheLoader</class-name>
              <init-params>
                <init-param>
                  <param-type>String</param-type>
                  <param-value>{cache-name}</param-value>
                </init-param>
              </init-params>
            </class-scheme>
          </cachestore-scheme>
          In your configuration you specify an init-param of type String so you must have a constructor with the same signature. E.G.
          public TestFixedCacheLoader(String cacheName) {
              super();
              logger.log(Level.INFO, "START TestFixedCacheLoader - INITIALIZED "); 
          }
          JK
          • 2. Re: AbstractCacheLoader does not get initialized
            909220
            hi jonathan,

            i've checked having both constructors with and without string with no result.

            this is a soa suite installation, there appear to be no errors in the logs and i can directly do the
            testCache.put(key, value);
            and
            testCache.get(key, value);

            independently however the CacheLoader does not get invoked i have to manually check if the get returns null and put the value in the the cache for future use.

            also i've lowered the
            <high-units>3</high-units>
            <expiry-delay>1m</expiry-delay>

            but i am noticing that the values are not expiring....
            • 3. Re: AbstractCacheLoader does not get initialized
              Jonathan.Knight
              Hi,

              Are you sure your cache configuration file is the one being used by Coherence. You should be able to see in the logs at startup where Coherence is reading the log file from. As the Coherence jar file contains a configuration file this will be used by default if you do not properly specify the configuration to use. You should see something like this...
              Oracle Coherence Version 3.7.1.7 Build 39785
               Grid Edition: Development mode
              Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
              
              2013-02-13 07:51:08.674/5.078 Oracle Coherence GE 3.7.1.7 <Info> (thread=main, member=n/a): Loaded cache configuration from "file:/C:/Stories/Trunk/trunk/out/production/odc-core/config/cluster-with-extend-32000.xml"; this document does not refer to any schema definition and has not been validated.
              JK
              • 4. Re: AbstractCacheLoader does not get initialized
                909220
                well first time using coherence... so a lot of mistakes...

                i was using the java classes and configs directly in the soa composite with no result.

                moved the exact same configs of the coherence to the coherence server started by soa infra and moved the java classes to a jar file in the soa server.