本文介绍了Apache Ignite - java.lang.ClassNotFoundException:未知对的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我最后一次尝试将 Apache Ignite 2.0 配置为使用Cassandra作为持久层和ODBC作为查询层。



ODBC配置没问题,我可以使用sql在缓存中放入和获取数据,但是当我插入Cassandra(版本3.9通过docker image)作为持久层时我明白了:

  java.lang.ClassNotFoundException:未知对[platformId = 0,typeId = 1262449073] 

我尝试使用Google搜索此异常,但没有得到任何有用的提示。



这是我的 Ignite配置

  boolean persistence = true; 

IgniteConfiguration cfg = new IgniteConfiguration();
CacheConfiguration< String,ValueClass> configuration = new CacheConfiguration< String,ValueClass>();

configuration.setName(test-cache);
configuration.setIndexedTypes(String.class,ValueClass.class);

if(persistence){
//配置Cassandra的持久性
DataSource dataSource = new DataSource();
dataSource.setContactPoints(172.17.0.2);
RoundRobinPolicy robinPolicy = new RoundRobinPolicy();
dataSource.setLoadBalancingPolicy(robinPolicy);
dataSource.setReadConsistency(ONE);
dataSource.setWriteConsistency(ONE);
String persistenceSettingsXml = FileUtils.readFileToString(new File(persistenceSettingsConfig),utf-8);
KeyValuePersistenceSettings persistenceSettings = new KeyValuePersistenceSettings(persistenceSettingsXml);
CassandraCacheStoreFactory cacheStoreFactory = new CassandraCacheStoreFactory();
cacheStoreFactory.setDataSource(dataSource);
cacheStoreFactory.setPersistenceSettings(persistenceSettings);
configuration.setCacheStoreFactory(cacheStoreFactory);
configuration.setWriteThrough(true);
configuration.setReadThrough(true);
configuration.setWriteBehindEnabled(true);
}

//设置缓存配置
cfg.setCacheConfiguration(configuration);

//配置ODBC
OdbcConfiguration odbcConfig = new OdbcConfiguration();
odbcConfig.setMaxOpenCursors(100);
cfg.setOdbcConfiguration(odbcConfig);

//开始点燃
点燃ignite = Ignition.start(cfg);

ValueClass:

 公共类ValueClass实现Serializable {
@QuerySqlField
private Integer numberOne;
@QuerySqlField
private整数numberTwo;

public Integer getNumberOne(){return numberOne; }

public Integer getNumberTwo(){return numberTwo; }

public void setNumberOne(整数值){
numberOne = value;
}
public void setNumberTwo(整数值){
numberTwo = value;
}
}

持久性配置:

 < persistence keyspace =ignitetable =odbc_testttl =86400> 
< keyspaceOptions>
REPLICATION = {'class':'SimpleStrategy','replication_factor':1}
AND DURABLE_WRITES = true
< / keyspaceOptions>

< tableOption>
comment ='缓存测试'
AND read_repair_chance = 0.2
< / tableOption>

< keyPersistence class =java.lang.Stringstrategy =PRIMITIVEcolumn =key/>

< valuePersistence class =com.riccamini.ignite.ValueClassstrategy =POJO>
< value name =numberOnecolumn =number_one/>
< value name =numberTwocolumn =number_two/>
< / valuePersistence>
< / persistence>

完成堆栈跟踪

  SEVERE:< test-cache>缓存更新期间出现意外异常
class org.apache.ignite.IgniteException:搜索行上的运行时故障:org.apache.inite.processors.cache.IgniteCacheOffheapManagerImpl$SearchRow@6380d269
org.apache。 ignite.internal.processors.cache.database.tree.BPlusTree.invoke(BPlusTree.java:1615)
at org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManagerImpl $ CacheDataStoreImpl.invoke(IgniteCacheOffheapManagerImpl.java:925 )
at org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManagerImpl.invoke(IgniteCacheOffheapManagerImpl.java:326)
at org.apache.ignite.internal.processors.cache.GridCacheMapEntry.innerUpdate(GridCacheMapEntry)在.orga: .processors.cache.distributed.dht.atomic.GridDhtAtomicCache.updateAllAsyncInternal0(GridDhtAtomicCache .java:1792)
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.updateAllAsyncInternal(GridDhtAtomicCache.java:1630)
at org.apache.ignite.internal .processors.cache.distributed.dht.atomic.GridNearAtomicAbstractUpdateFuture.sendSingleRequest(GridNearAtomicAbstractUpdateFuture.java:299)
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicSingleUpdateFuture.map(GridNearAtomicSingleUpdateFuture。 java:480)
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicSingleUpdateFuture.mapOnTopology(GridNearAtomicSingleUpdateFuture.java:440)
at org.apache.ignite.internal。 processors.cache.distributed.dht.atomic.GridNearAtomicAbstractUpdateFuture.map(GridNearAtomicAbstractUpdateFuture.java:248)
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.update0(GridDhtAtomicCache.java) :1162)org.apache.ignite.int上的
ernal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.put0(GridDhtAtomicCache.java:651)
at org.apache.ignite.internal.processors.cache.GridCacheAdapter.put(GridCacheAdapter.java:2345)
at org.apache.ignite.internal.processors.cache.GridCacheAdapter.putIfAbsent(GridCacheAdapter.java:2720)
at org.apache.ignite.internal.processors.query.h2.DmlStatementsProcessor.doInsert(DmlStatementsProcessor) .java:829)
at org.apache.ignite.internal.processors.query.h2.DmlStatementsProcessor.executeUpdateStatement(DmlStatementsProcessor.java:369)
at org.apache.ignite.internal.processors.query .h2.DmlStatementsProcessor.updateSqlFields(DmlStatementsProcessor.java:164)
at org.apache.ignite.internal.processors.query.h2.DmlStatementsProcessor.updateSqlFieldsTwoStep(DmlStatementsProcessor.java:198)
at org.apache .ignite.internal.processors.query.h2.IgniteH2Indexing.queryTwoStep(IgniteH2Indexing.java:1659)org.apache.ignite.inter上的
nal.processors.query.GridQueryProcessor $ 4.applyx(GridQueryProcessor.java:1659)
at org.apache.ignite.internal.processors.query.GridQueryProcessor $ 4.applyx(GridQueryProcessor.java:1657)
at org.apache.ignite.internal.util.lang.IgniteOutClosureX.apply(IgniteOutClosureX.java:36)
at org.apache.ignite.internal.processors.query.GridQueryProcessor.executeQuery(GridQueryProcessor.java:2103)
at org.apache.ignite.internal.processors.query.GridQueryProcessor.queryTwoStep(GridQueryProcessor.java:1657)
at org.apache.ignite.internal.processors.cache.IgniteCacheProxy.query(IgniteCacheProxy.java :806)
at org.apache.ignite.internal.processors.odbc.OdbcRequestHandler.executeQuery(OdbcRequestHandler.java:213)
at org.apache.ignite.internal.processors.odbc.OdbcRequestHandler.handle (OdbcRequestHandler.java:108)
at org.apache.ignite.internal.processors.odbc.OdbcNioListener.onMessage(OdbcNioListener.java:124)
at org.apache.ignite.in ternal.processors.odbc.OdbcNioListener.onMessage(OdbcNioListener.java:33)
at org.apache.ignite.internal.util.nio.GridNioFilterChain $ TailFilter.onMessageReceived(GridNioFilterChain.java:279)
at org.apache.ignite.internal.util.nio.GridNioFilterAdapter.proceedMessageReceived(GridNioFilterAdapter.java:109)
at org.apache.ignite.internal.util.nio.GridNioAsyncNotifyFilter $ 3.body(GridNioAsyncNotifyFilter.java:97)
at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
at org.apache.ignite.internal.util.worker.GridWorkerPool $ 1.run(GridWorkerPool) .java:70)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
引起:class org.apache.ignite.binary.BinaryInvalidTypeException:未知对[platformId = 0,typeId = 1262449073]
在org.apache.ig nite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:701)
at org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize0(BinaryReaderExImpl.java:1745)
at org.apache。 ignite.internal.binary.BinaryReaderExImpl.deserialize(BinaryReaderExImpl.java:1704)
at org.apache.ignite.internal.binary.BinaryObjectImpl.deserializeValue(BinaryObjectImpl.java:794)
at org.apache。 ignite.internal.binary.BinaryObjectImpl.value(BinaryObjectImpl.java:142)
at org.apache.ignite.internal.processors.cache.CacheObjectContext.unwrapBinary(CacheObjectContext.java:273)
at org。 apache.ignite.internal.processors.cache.CacheObjectContext.unwrapBinaryIfNeeded(CacheObjectContext.java:161)
at org.apache.ignite.internal.processors.cache.CacheObjectContext.unwrapBinaryIfNeeded(CacheObjectContext.java:148)
at org.apache.ignite.internal.processors.cache.GridCacheContext.unwrapBinaryIfNeeded(GridCacheContext.java:1730)
at or or g.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.put(GridCacheStoreManagerAdapter.java:555)
at org.apache.ignite.internal.processors.cache.GridCacheMapEntry $ AtomicCacheUpdateClosure.update(GridCacheMapEntry.java) :4404)
at org.apache.ignite.internal.processors.cache.GridCacheMapEntry $ AtomicCacheUpdateClosure.call(GridCacheMapEntry.java:4226)
at org.apache.ignite.internal.processors.cache.GridCacheMapEntry $ AtomicCacheUpdateClosure.call(GridCacheMapEntry.java:3966)
at org.apache.ignite.internal.processors.cache.database.tree.BPlusTree $ Invoke.invokeClosure(BPlusTree.java:2966)
at org .apache.ignite.internal.processors.cache.database.tree.BPlusTree $ Invoke.access $ 6200(BPlusTree.java:2860)
at org.apache.ignite.internal.processors.cache.database.tree.BPlusTree .invokeDown(BPlusTree.java:1696)
at org.apache.ignite.internal.processors.cache.database.tree.BPlusTree.invoke(BPlusTree.java:1585)
... 37 m ore
引起:java.lang.ClassNotFoundException:未知对[platformId = 0,typeId = 1262449073]
at org.apache.ignite.internal.MarshallerContextImpl.getClassName(MarshallerContextImpl.java:385)
at org.apache.ignite.internal.MarshallerContextImpl.getClass(MarshallerContextImpl.java:335)
at org.apache.ignite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:692)
... 53更多

Jun 28,2017 10:02:41 AM org.apache.ignite.logger.java.JavaLogger错误
严重:执行SQL查询失败[reqId = 2 ,req = OdbcQueryExecuteRequest [cacheName = test-cache,sqlQry = INSERT INTO valueclass(_key,numberone,numbertwo)VALUES('testkey2',10,10),args = []]]
javax.cache.CacheException: class org.apache.ignite.internal.processors.query.IgniteSQLException:无法执行DML语句[stmt = INSERT INTO valueclass(_key,numberone,numbertwo)VALUES('testkey2',10,10),params = []]
at org.apache.ignite.internal.pro cessors.cache.IgniteCacheProxy.query(IgniteCacheProxy.java:818)
at org.apache.ignite.internal.processors.odbc.OdbcRequestHandler.executeQuery(OdbcRequestHandler.java:213)
at org.apache。 ignite.internal.processors.odbc.OdbcRequestHandler.handle(OdbcRequestHandler.java:108)
at org.apache.ignite.internal.processors.odbc.OdbcNioListener.onMessage(OdbcNioListener.java:124)
at org.apache.ignite.internal.processors.odbc.OdbcNioListener.onMessage(OdbcNioListener.java:33)
at org.apache.ignite.internal.util.nio.GridNioFilterChain $ TailFilter.onMessageReceived(GridNioFilterChain.java:279 )
at org.apache.ignite.internal.util.nio.GridNioFilterAdapter.proceedMessageReceived(GridNioFilterAdapter.java:109)
at org.apache.ignite.internal.util.nio.GridNioAsyncNotifyFilter $ 3.body(在网站上,org.apache.ignite。 er.GridWorkerPool $ 1.run(GridWorkerPool.java:70)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor $ Worker.run (ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
引起:class org.apache.ignite.internal.processors.query.IgniteSQLException:失败在org.apache.ignite.internal.processors.query.h2执行DML语句[stmt = INSERT INTO valueclass(_key,numberone,numbertwo)VALUES('testkey2',10,10),params = []]
.IgniteH2Indexing.queryTwoStep(IgniteH2Indexing.java:1662)
at org.apache.ignite.internal.processors.query.GridQueryProcessor $ 4.applyx(GridQueryProcessor.java:1659)
at org.apache.ignite。 internal.processors.query.GridQueryProcessor $ 4.applyx(GridQueryProcessor.java:1657)
at org.apache.ignite.internal.util.lang.IgniteOutClosureX.apply(IgniteOutClosureX.java:36)
at org .apache.ignite.internal.processors.que ry.GridQueryProcessor.executeQuery(GridQueryProcessor.java:2103)
at org.apache.ignite.internal.processors.query.GridQueryProcessor.queryTwoStep(GridQueryProcessor.java:1657)
at org.apache.ignite。 internal.processors.cache.IgniteCacheProxy.query(IgniteCacheProxy.java:806)
... 12 more
引起:class org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException:无法更新密钥(如果可能,重试更新):[testkey2]
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicAbstractUpdateFuture.onPrimaryError(GridNearAtomicAbstractUpdateFuture.java:397)
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicSingleUpdateFuture.onPrimaryResponse(GridNearAtomicSingleUpdateFuture.java:250)
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic .GridNearAtomicAbstractUpdateFuture $ 1.apply(GridNearAtomicAbstractUpdateFuture.java:303)
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicAbstractUpdateFuture $ 1.apply(GridNearAtomicAbstractUpdateFuture.java:300)
at org.apache.ignite.internal.processors.cache.distributed.dht。 atomic.GridDhtAtomicCache.updateAllAsyncInternal0(GridDhtAtomicCache.java:1885)
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.updateAllAsyncInternal(GridDhtAtomicCache.java:1630)
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicAbstractUpdateFuture.sendSingleRequest(GridNearAtomicAbstractUpdateFuture.java:299)
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic .GridNearAtomicSingleUpdateFuture.map(GridNearAtomicSingleUpdateFuture.java:480)
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicSingleUpdateFuture.mapOnTopology(GridNearAtomicSingleUpdateFuture.java:440)
at org .apache.ignite.interna l.processors.cache.distributed.dht.atomic.GridNearAtomicAbstractUpdateFuture.map(GridNearAtomicAbstractUpdateFuture.java:248)
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.update0(GridDhtAtomicCache) .java:1162)
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.put0(GridDhtAtomicCache.java:651)
at org.apache.ignite.internal .processors.cache.GridCacheAdapter.put(GridCacheAdapter.java:2345)
at org.apache.ignite.internal.processors.cache.GridCacheAdapter.putIfAbsent(GridCacheAdapter.java:2720)
at org.apache .ignite.internal.processors.query.h2.DmlStatementsProcessor.doInsert(DmlStatementsProcessor.java:829)
at org.apache.ignite.internal.processors.query.h2.DmlStatementsProcessor.executeUpdateStatement(DmlStatementsProcessor.java:369)
at org.apache.ignite.internal.processors.query.h2.DmlStatementsProcessor.updateSqlFields(DmlStatementsProcessor.java: 164)
at org.apache.ignite.internal.processors.query.h2.DmlStatementsProcessor.updateSqlFieldsTwoStep(DmlStatementsProcessor.java:198)
at org.apache.ignite.internal.processors.query.h2。 IgniteH2Indexing.queryTwoStep(IgniteH2Indexing.java:1659)
... 18更多
抑制:class org.apache.ignite.IgniteCheckedException:无法更新主节点上的密钥。
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.UpdateErrors.addFailedKeys(UpdateErrors.java:124)
at org.apache.ignite.internal.processors.cache。 distributed.dht.atomic.GridNearAtomicUpdateResponse.addFailedKeys(GridNearAtomicUpdateResponse.java:342)
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.updateAllAsyncInternal0(GridDhtAtomicCache.java:1883)
... 32更多
禁止:类org.apache.ignite.IgniteException:搜索行上的运行时失败:org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManagerImpl$SearchRow@6380d269
在org.apache.ignite.internal.processors.cache.database.tree.BPlusTree.invoke(BPlusTree.java:1615)
at org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManagerImpl $ CacheDataStoreImpl.invoke( IgniteCacheOffheapManagerImpl.java:925)org.apache.ignite.internal.processo上的
rs.cache.IgniteCacheOffheapManagerImpl.invoke(IgniteCacheOffheapManagerImpl.java:326)
at org.apache.ignite.internal.processors.cache.GridCacheMapEntry.innerUpdate(GridCacheMapEntry.java:1693)
at org.apache。 ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.updateSingle(GridDhtAtomicCache.java:2386)
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.updateAllAsyncInternal0 (GridDhtAtomicCache.java:1792)
... 32更多
引起:class org.apache.ignite.binary.BinaryInvalidTypeException:未知对[platformId = 0,typeId = 1262449073]
at org.apache.ignite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:701)
at org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize0(BinaryReaderExImpl.java:1745)
at org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize(了BinaryRead erExImpl.java:1704)
at org.apache.ignite.internal.binary.BinaryObjectImpl.deserializeValue(BinaryObjectImpl.java:794)
at org.apache.ignite.internal.binary.BinaryObjectImpl.value( BinaryObjectImpl.java:142)
at org.apache.ignite.internal.processors.cache.CacheObjectContext.unwrapBinary(CacheObjectContext.java:273)
at org.apache.ignite.internal.processors.cache。 CacheObjectContext.unwrapBinaryIfNeeded(CacheObjectContext.java:161)
at org.apache.ignite.internal.processors.cache.CacheObjectContext.unwrapBinaryIfNeeded(CacheObjectContext.java:148)
at org.apache.ignite.internal。 processors.cache.GridCacheContext.unwrapBinaryIfNeeded(GridCacheContext.java:1730)
at org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.put(GridCacheStoreManagerAdapter.java:555)
at org。 apache.ignite.internal.processors.cache.GridCacheMapEntry $ AtomicCacheUpdat eClosure.update(GridCacheMapEntry.java:4404)
at org.apache.ignite.internal.processors.cache.GridCacheMapEntry $ AtomicCacheUpdateClosure.call(GridCacheMapEntry.java:4226)
at org.apache.ignite。 internal.processors.cache.GridCacheMapEntry $ AtomicCacheUpdateClosure.call(GridCacheMapEntry.java:3966)
at org.apache.ignite.internal.processors.cache.database.tree.BPlusTree $ Invoke.invokeClosure(BPlusTree.java:2966 )
at org.apache.ignite.internal.processors.cache.database.tree.BPlusTree $ Invoke.access $ 6200(BPlusTree.java:2860)
at org.apache.ignite.internal.processors。 cache.database.tree.BPlusTree.invokeDown(BPlusTree.java:1696)
at org.apache.ignite.internal.processors.cache.database.tree.BPlusTree.invoke(BPlusTree.java:1585)
... 37更多
引起:java.lang.ClassNotFoundException:未知对[platformId = 0,typeId = 1262449073]
at org.apache.ignite.interna l.MarshallerContextImpl.getClassName(MarshallerContextImpl.java:385)
at org.apache.ignite.internal.MarshallerContextImpl.getClass(MarshallerContextImpl.java:335)
at org.apache.ignite.internal.binary。 BinaryContext.descriptorForTypeId(BinaryContext.java:692)
... 53更多

任何建议非常感谢。

解决方案

请尝试在缓存中启用 isStoreKeepBinary 设置 - 像这样;请注意最后一行:

  if(persistence){
//配置Cassandra的持久性
DataSource dataSource = new DataSource();
// ...这里显示现在出现的其余设置...
configuration.setWriteBehindEnabled(true);

configuration.setStoreKeepBinary(true);
}

此设置强制Ignite在使用底层缓存存储时避免二进制反序列化。 / p>

this is my last attempt to configure Apache Ignite 2.0 to work with Cassandra as persistence layer and ODBC as query layer.

ODBC configuration is ok, I am able to put and get data in the cache with sql, but when I plug in Cassandra (version 3.9 via docker image) as persistence layer I get this:

java.lang.ClassNotFoundException: Unknown pair [platformId=0, typeId=1262449073]

I tried googling around for this exception but got no useful hint.

Here's my Ignite configuration:

        boolean persistence = true;

        IgniteConfiguration cfg = new IgniteConfiguration();
        CacheConfiguration<String, ValueClass> configuration = new CacheConfiguration<String, ValueClass>();

        configuration.setName("test-cache");
        configuration.setIndexedTypes(String.class, ValueClass.class);

        if(persistence){
            //  Configuring Cassandra's persistence
            DataSource dataSource = new DataSource();
            dataSource.setContactPoints("172.17.0.2");
            RoundRobinPolicy robinPolicy = new RoundRobinPolicy();
            dataSource.setLoadBalancingPolicy(robinPolicy);
            dataSource.setReadConsistency("ONE");
            dataSource.setWriteConsistency("ONE");
            String persistenceSettingsXml = FileUtils.readFileToString(new File(persistenceSettingsConfig), "utf-8");
            KeyValuePersistenceSettings persistenceSettings = new KeyValuePersistenceSettings(persistenceSettingsXml);
            CassandraCacheStoreFactory cacheStoreFactory = new CassandraCacheStoreFactory();
            cacheStoreFactory.setDataSource(dataSource);
            cacheStoreFactory.setPersistenceSettings(persistenceSettings);
            configuration.setCacheStoreFactory(cacheStoreFactory);
            configuration.setWriteThrough(true);
            configuration.setReadThrough(true);
            configuration.setWriteBehindEnabled(true);
        }

        //  Setting cache configuration
        cfg.setCacheConfiguration(configuration);

        //  Configuring ODBC
        OdbcConfiguration odbcConfig = new OdbcConfiguration();
        odbcConfig.setMaxOpenCursors(100);
        cfg.setOdbcConfiguration(odbcConfig);

        //  Starting Ignite
        Ignite ignite = Ignition.start(cfg);

ValueClass:

public class ValueClass implements Serializable{
    @QuerySqlField
    private Integer numberOne;
    @QuerySqlField
    private Integer numberTwo;

    public Integer getNumberOne(){ return numberOne; }

    public Integer getNumberTwo(){ return numberTwo; }

    public void setNumberOne(Integer value){
        numberOne = value;
    }
    public void setNumberTwo(Integer value){
        numberTwo = value;
    }
}

Persistence configuration:

<persistence keyspace="ignite" table="odbc_test" ttl="86400">
    <keyspaceOptions>
        REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor' : 1}
        AND DURABLE_WRITES = true
    </keyspaceOptions>

    <tableOption>
        comment = 'Cache test'
        AND read_repair_chance = 0.2
    </tableOption>

    <keyPersistence class="java.lang.String" strategy="PRIMITIVE" column="key" />

    <valuePersistence class="com.riccamini.ignite.ValueClass" strategy="POJO">
        <value name="numberOne" column="number_one"/>
        <value name="numberTwo" column="number_two"/>
    </valuePersistence>
</persistence>

Complete stack trace:

SEVERE: <test-cache> Unexpected exception during cache update
class org.apache.ignite.IgniteException: Runtime failure on search row: org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManagerImpl$SearchRow@6380d269
    at org.apache.ignite.internal.processors.cache.database.tree.BPlusTree.invoke(BPlusTree.java:1615)
    at org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManagerImpl$CacheDataStoreImpl.invoke(IgniteCacheOffheapManagerImpl.java:925)
    at org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManagerImpl.invoke(IgniteCacheOffheapManagerImpl.java:326)
    at org.apache.ignite.internal.processors.cache.GridCacheMapEntry.innerUpdate(GridCacheMapEntry.java:1693)
    at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.updateSingle(GridDhtAtomicCache.java:2386)
    at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.updateAllAsyncInternal0(GridDhtAtomicCache.java:1792)
    at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.updateAllAsyncInternal(GridDhtAtomicCache.java:1630)
    at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicAbstractUpdateFuture.sendSingleRequest(GridNearAtomicAbstractUpdateFuture.java:299)
    at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicSingleUpdateFuture.map(GridNearAtomicSingleUpdateFuture.java:480)
    at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicSingleUpdateFuture.mapOnTopology(GridNearAtomicSingleUpdateFuture.java:440)
    at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicAbstractUpdateFuture.map(GridNearAtomicAbstractUpdateFuture.java:248)
    at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.update0(GridDhtAtomicCache.java:1162)
    at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.put0(GridDhtAtomicCache.java:651)
    at org.apache.ignite.internal.processors.cache.GridCacheAdapter.put(GridCacheAdapter.java:2345)
    at org.apache.ignite.internal.processors.cache.GridCacheAdapter.putIfAbsent(GridCacheAdapter.java:2720)
    at org.apache.ignite.internal.processors.query.h2.DmlStatementsProcessor.doInsert(DmlStatementsProcessor.java:829)
    at org.apache.ignite.internal.processors.query.h2.DmlStatementsProcessor.executeUpdateStatement(DmlStatementsProcessor.java:369)
    at org.apache.ignite.internal.processors.query.h2.DmlStatementsProcessor.updateSqlFields(DmlStatementsProcessor.java:164)
    at org.apache.ignite.internal.processors.query.h2.DmlStatementsProcessor.updateSqlFieldsTwoStep(DmlStatementsProcessor.java:198)
    at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.queryTwoStep(IgniteH2Indexing.java:1659)
    at org.apache.ignite.internal.processors.query.GridQueryProcessor$4.applyx(GridQueryProcessor.java:1659)
    at org.apache.ignite.internal.processors.query.GridQueryProcessor$4.applyx(GridQueryProcessor.java:1657)
    at org.apache.ignite.internal.util.lang.IgniteOutClosureX.apply(IgniteOutClosureX.java:36)
    at org.apache.ignite.internal.processors.query.GridQueryProcessor.executeQuery(GridQueryProcessor.java:2103)
    at org.apache.ignite.internal.processors.query.GridQueryProcessor.queryTwoStep(GridQueryProcessor.java:1657)
    at org.apache.ignite.internal.processors.cache.IgniteCacheProxy.query(IgniteCacheProxy.java:806)
    at org.apache.ignite.internal.processors.odbc.OdbcRequestHandler.executeQuery(OdbcRequestHandler.java:213)
    at org.apache.ignite.internal.processors.odbc.OdbcRequestHandler.handle(OdbcRequestHandler.java:108)
    at org.apache.ignite.internal.processors.odbc.OdbcNioListener.onMessage(OdbcNioListener.java:124)
    at org.apache.ignite.internal.processors.odbc.OdbcNioListener.onMessage(OdbcNioListener.java:33)
    at org.apache.ignite.internal.util.nio.GridNioFilterChain$TailFilter.onMessageReceived(GridNioFilterChain.java:279)
    at org.apache.ignite.internal.util.nio.GridNioFilterAdapter.proceedMessageReceived(GridNioFilterAdapter.java:109)
    at org.apache.ignite.internal.util.nio.GridNioAsyncNotifyFilter$3.body(GridNioAsyncNotifyFilter.java:97)
    at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
    at org.apache.ignite.internal.util.worker.GridWorkerPool$1.run(GridWorkerPool.java:70)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:748)
Caused by: class org.apache.ignite.binary.BinaryInvalidTypeException: Unknown pair [platformId=0, typeId=1262449073]
    at org.apache.ignite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:701)
    at org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize0(BinaryReaderExImpl.java:1745)
    at org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize(BinaryReaderExImpl.java:1704)
    at org.apache.ignite.internal.binary.BinaryObjectImpl.deserializeValue(BinaryObjectImpl.java:794)
    at org.apache.ignite.internal.binary.BinaryObjectImpl.value(BinaryObjectImpl.java:142)
    at org.apache.ignite.internal.processors.cache.CacheObjectContext.unwrapBinary(CacheObjectContext.java:273)
    at org.apache.ignite.internal.processors.cache.CacheObjectContext.unwrapBinaryIfNeeded(CacheObjectContext.java:161)
    at org.apache.ignite.internal.processors.cache.CacheObjectContext.unwrapBinaryIfNeeded(CacheObjectContext.java:148)
    at org.apache.ignite.internal.processors.cache.GridCacheContext.unwrapBinaryIfNeeded(GridCacheContext.java:1730)
    at org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.put(GridCacheStoreManagerAdapter.java:555)
    at org.apache.ignite.internal.processors.cache.GridCacheMapEntry$AtomicCacheUpdateClosure.update(GridCacheMapEntry.java:4404)
    at org.apache.ignite.internal.processors.cache.GridCacheMapEntry$AtomicCacheUpdateClosure.call(GridCacheMapEntry.java:4226)
    at org.apache.ignite.internal.processors.cache.GridCacheMapEntry$AtomicCacheUpdateClosure.call(GridCacheMapEntry.java:3966)
    at org.apache.ignite.internal.processors.cache.database.tree.BPlusTree$Invoke.invokeClosure(BPlusTree.java:2966)
    at org.apache.ignite.internal.processors.cache.database.tree.BPlusTree$Invoke.access$6200(BPlusTree.java:2860)
    at org.apache.ignite.internal.processors.cache.database.tree.BPlusTree.invokeDown(BPlusTree.java:1696)
    at org.apache.ignite.internal.processors.cache.database.tree.BPlusTree.invoke(BPlusTree.java:1585)
    ... 37 more
Caused by: java.lang.ClassNotFoundException: Unknown pair [platformId=0, typeId=1262449073]
    at org.apache.ignite.internal.MarshallerContextImpl.getClassName(MarshallerContextImpl.java:385)
    at org.apache.ignite.internal.MarshallerContextImpl.getClass(MarshallerContextImpl.java:335)
    at org.apache.ignite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:692)
    ... 53 more

Jun 28, 2017 10:02:41 AM org.apache.ignite.logger.java.JavaLogger error
SEVERE: Failed to execute SQL query [reqId=2, req=OdbcQueryExecuteRequest [cacheName=test-cache, sqlQry=INSERT INTO valueclass (_key, numberone, numbertwo) VALUES ('testkey2', 10, 10), args=[]]]
javax.cache.CacheException: class org.apache.ignite.internal.processors.query.IgniteSQLException: Failed to execute DML statement [stmt=INSERT INTO valueclass (_key, numberone, numbertwo) VALUES ('testkey2', 10, 10), params=[]]
    at org.apache.ignite.internal.processors.cache.IgniteCacheProxy.query(IgniteCacheProxy.java:818)
    at org.apache.ignite.internal.processors.odbc.OdbcRequestHandler.executeQuery(OdbcRequestHandler.java:213)
    at org.apache.ignite.internal.processors.odbc.OdbcRequestHandler.handle(OdbcRequestHandler.java:108)
    at org.apache.ignite.internal.processors.odbc.OdbcNioListener.onMessage(OdbcNioListener.java:124)
    at org.apache.ignite.internal.processors.odbc.OdbcNioListener.onMessage(OdbcNioListener.java:33)
    at org.apache.ignite.internal.util.nio.GridNioFilterChain$TailFilter.onMessageReceived(GridNioFilterChain.java:279)
    at org.apache.ignite.internal.util.nio.GridNioFilterAdapter.proceedMessageReceived(GridNioFilterAdapter.java:109)
    at org.apache.ignite.internal.util.nio.GridNioAsyncNotifyFilter$3.body(GridNioAsyncNotifyFilter.java:97)
    at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
    at org.apache.ignite.internal.util.worker.GridWorkerPool$1.run(GridWorkerPool.java:70)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:748)
Caused by: class org.apache.ignite.internal.processors.query.IgniteSQLException: Failed to execute DML statement [stmt=INSERT INTO valueclass (_key, numberone, numbertwo) VALUES ('testkey2', 10, 10), params=[]]
    at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.queryTwoStep(IgniteH2Indexing.java:1662)
    at org.apache.ignite.internal.processors.query.GridQueryProcessor$4.applyx(GridQueryProcessor.java:1659)
    at org.apache.ignite.internal.processors.query.GridQueryProcessor$4.applyx(GridQueryProcessor.java:1657)
    at org.apache.ignite.internal.util.lang.IgniteOutClosureX.apply(IgniteOutClosureX.java:36)
    at org.apache.ignite.internal.processors.query.GridQueryProcessor.executeQuery(GridQueryProcessor.java:2103)
    at org.apache.ignite.internal.processors.query.GridQueryProcessor.queryTwoStep(GridQueryProcessor.java:1657)
    at org.apache.ignite.internal.processors.cache.IgniteCacheProxy.query(IgniteCacheProxy.java:806)
    ... 12 more
Caused by: class org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException: Failed to update keys (retry update if possible).: [testkey2]
    at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicAbstractUpdateFuture.onPrimaryError(GridNearAtomicAbstractUpdateFuture.java:397)
    at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicSingleUpdateFuture.onPrimaryResponse(GridNearAtomicSingleUpdateFuture.java:250)
    at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicAbstractUpdateFuture$1.apply(GridNearAtomicAbstractUpdateFuture.java:303)
    at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicAbstractUpdateFuture$1.apply(GridNearAtomicAbstractUpdateFuture.java:300)
    at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.updateAllAsyncInternal0(GridDhtAtomicCache.java:1885)
    at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.updateAllAsyncInternal(GridDhtAtomicCache.java:1630)
    at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicAbstractUpdateFuture.sendSingleRequest(GridNearAtomicAbstractUpdateFuture.java:299)
    at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicSingleUpdateFuture.map(GridNearAtomicSingleUpdateFuture.java:480)
    at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicSingleUpdateFuture.mapOnTopology(GridNearAtomicSingleUpdateFuture.java:440)
    at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicAbstractUpdateFuture.map(GridNearAtomicAbstractUpdateFuture.java:248)
    at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.update0(GridDhtAtomicCache.java:1162)
    at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.put0(GridDhtAtomicCache.java:651)
    at org.apache.ignite.internal.processors.cache.GridCacheAdapter.put(GridCacheAdapter.java:2345)
    at org.apache.ignite.internal.processors.cache.GridCacheAdapter.putIfAbsent(GridCacheAdapter.java:2720)
    at org.apache.ignite.internal.processors.query.h2.DmlStatementsProcessor.doInsert(DmlStatementsProcessor.java:829)
    at org.apache.ignite.internal.processors.query.h2.DmlStatementsProcessor.executeUpdateStatement(DmlStatementsProcessor.java:369)
    at org.apache.ignite.internal.processors.query.h2.DmlStatementsProcessor.updateSqlFields(DmlStatementsProcessor.java:164)
    at org.apache.ignite.internal.processors.query.h2.DmlStatementsProcessor.updateSqlFieldsTwoStep(DmlStatementsProcessor.java:198)
    at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.queryTwoStep(IgniteH2Indexing.java:1659)
    ... 18 more
    Suppressed: class org.apache.ignite.IgniteCheckedException: Failed to update keys on primary node.
        at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.UpdateErrors.addFailedKeys(UpdateErrors.java:124)
        at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicUpdateResponse.addFailedKeys(GridNearAtomicUpdateResponse.java:342)
        at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.updateAllAsyncInternal0(GridDhtAtomicCache.java:1883)
        ... 32 more
        Suppressed: class org.apache.ignite.IgniteException: Runtime failure on search row: org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManagerImpl$SearchRow@6380d269
            at org.apache.ignite.internal.processors.cache.database.tree.BPlusTree.invoke(BPlusTree.java:1615)
            at org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManagerImpl$CacheDataStoreImpl.invoke(IgniteCacheOffheapManagerImpl.java:925)
            at org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManagerImpl.invoke(IgniteCacheOffheapManagerImpl.java:326)
            at org.apache.ignite.internal.processors.cache.GridCacheMapEntry.innerUpdate(GridCacheMapEntry.java:1693)
            at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.updateSingle(GridDhtAtomicCache.java:2386)
            at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.updateAllAsyncInternal0(GridDhtAtomicCache.java:1792)
            ... 32 more
        Caused by: class org.apache.ignite.binary.BinaryInvalidTypeException: Unknown pair [platformId=0, typeId=1262449073]
            at org.apache.ignite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:701)
            at org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize0(BinaryReaderExImpl.java:1745)
            at org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize(BinaryReaderExImpl.java:1704)
            at org.apache.ignite.internal.binary.BinaryObjectImpl.deserializeValue(BinaryObjectImpl.java:794)
            at org.apache.ignite.internal.binary.BinaryObjectImpl.value(BinaryObjectImpl.java:142)
            at org.apache.ignite.internal.processors.cache.CacheObjectContext.unwrapBinary(CacheObjectContext.java:273)
            at org.apache.ignite.internal.processors.cache.CacheObjectContext.unwrapBinaryIfNeeded(CacheObjectContext.java:161)
            at org.apache.ignite.internal.processors.cache.CacheObjectContext.unwrapBinaryIfNeeded(CacheObjectContext.java:148)
            at org.apache.ignite.internal.processors.cache.GridCacheContext.unwrapBinaryIfNeeded(GridCacheContext.java:1730)
            at org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.put(GridCacheStoreManagerAdapter.java:555)
            at org.apache.ignite.internal.processors.cache.GridCacheMapEntry$AtomicCacheUpdateClosure.update(GridCacheMapEntry.java:4404)
            at org.apache.ignite.internal.processors.cache.GridCacheMapEntry$AtomicCacheUpdateClosure.call(GridCacheMapEntry.java:4226)
            at org.apache.ignite.internal.processors.cache.GridCacheMapEntry$AtomicCacheUpdateClosure.call(GridCacheMapEntry.java:3966)
            at org.apache.ignite.internal.processors.cache.database.tree.BPlusTree$Invoke.invokeClosure(BPlusTree.java:2966)
            at org.apache.ignite.internal.processors.cache.database.tree.BPlusTree$Invoke.access$6200(BPlusTree.java:2860)
            at org.apache.ignite.internal.processors.cache.database.tree.BPlusTree.invokeDown(BPlusTree.java:1696)
            at org.apache.ignite.internal.processors.cache.database.tree.BPlusTree.invoke(BPlusTree.java:1585)
            ... 37 more
        Caused by: java.lang.ClassNotFoundException: Unknown pair [platformId=0, typeId=1262449073]
            at org.apache.ignite.internal.MarshallerContextImpl.getClassName(MarshallerContextImpl.java:385)
            at org.apache.ignite.internal.MarshallerContextImpl.getClass(MarshallerContextImpl.java:335)
            at org.apache.ignite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:692)
            ... 53 more

Any suggestion is really appreciated.

解决方案

Please try to turn on isStoreKeepBinary in cache settings - like this; please note the last line:

if (persistence){
        //  Configuring Cassandra's persistence
        DataSource dataSource = new DataSource();
        // ...here go the rest of your settings as they appear now...
        configuration.setWriteBehindEnabled(true);

        configuration.setStoreKeepBinary(true);
    }

This setting forces Ignite to avoid binary deserialization when working with underlying cache store.

这篇关于Apache Ignite - java.lang.ClassNotFoundException:未知对的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 15:52