Ignite CacheStore implementation throwing ClassNotFoundException at server side

373 views Asked by At

I am implementing CacheStore to write data asyn in database. Code is working fine while running Ignite inside application as "Server" and data is getting saved in database.

Problematic scenerio : Running remote node as server and application as "client", While starting client node already started server nodes throws ClassNotFoundException.

Following are my configurations:

Server

<bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
    <property name="metricsLogFrequency" value="0"/>
    <property name="peerClassLoadingEnabled" value="true"/>
    <property name="marshaller">
            <bean class="org.apache.ignite.marshaller.optimized.OptimizedMarshaller">
            <!-- Set to false to allow non-serializable objects in examples, default is true. -->
            <property name="requireSerializable" value="false"/>
        </bean>
        </property>

    <property name="discoverySpi">
        <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
            <property name="ipFinder">
            <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.zk.TcpDiscoveryZookeeperIpFinder">
                <property name="zkConnectionString" value="localhost:2181"/>
            </bean>
            </property>
        </bean>
    </property>
</bean>

Client :

CacheConfiguration cacheConfiguration = new CacheConfiguration();
cacheConfiguration.setName(name);
cacheConfiguration.setBackups(backup);
cacheConfiguration.setRebalanceMode(CacheRebalanceMode.SYNC);
cacheConfiguration.setCacheMode(CacheMode.PARTITIONED);
LruEvictionPolicy evictionPolicy = new LruEvictionPolicy();
evictionPolicy.setMaxSize(maxEntries);
cacheConfiguration.setEvictionPolicy(evictionPolicy);
cacheConfiguration.setEvictSynchronized(true);
cacheConfiguration.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(duration));
cacheConfiguration.setStartSize(100*1024*1024);
cacheConfiguration.setReadThrough(true);
cacheConfiguration.setWriteThrough(true);
cacheConfiguration.setWriteBehindEnabled(true);
cacheConfiguration.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
cacheConfiguration.setCacheStoreFactory(new FactoryBuilder.SingletonFactory<CacheStore>(cacheStore));



IgniteConfiguration igniteConfiguration = new IgniteConfiguration();
igniteConfiguration.setPeerClassLoadingEnabled(true);
TcpDiscoverySpi tcpDiscoverySpi = new TcpDiscoverySpi();
TcpDiscoveryZookeeperIpFinder ipFinder = new TcpDiscoveryZookeeperIpFinder();
ipFinder.setZkConnectionString(zookeeperConString);
tcpDiscoverySpi.setIpFinder(ipFinder);

OptimizedMarshaller marshaller = new OptimizedMarshaller();
marshaller.setRequireSerializable(false);

igniteConfiguration.
                setCacheConfiguration(cacheConfiguration).
                setClientMode(isClient);
igniteConfiguration.setDiscoverySpi(tcpDiscoverySpi);
igniteConfiguration.setMarshaller(marshaller).
                setGridName(gridName).
                setMetricsLogFrequency(0);
SpringCacheManager springCacheManager = new SpringCacheManager();
springCacheManager.setConfiguration(igniteConfiguration);

Now, I dont want to deploy CacheStore on server node so I have enabled peerclassloading. But same exception was thrown so I check on internet and changed its atomicitymode to Transaction so CacheStore at Client will be used everytime. But still facing same issue.

1

There are 1 answers

3
Nikolay Tikhonov On

All classes which present in CacheConfiguration should be available on all nodes. P2P classloading doesn't work for CacheStore. You need to deploy classes manually.