Hi,
You can put different types of objects in your cache because of the
specific of its implementation. But this possibility can break your
ScanQuery because you are going to see in cache only StationDto objects.
I guess that previously you put ArrayList inside the cache and then you
put StationDto.
Please note that in case if you are going to change the ValueType of the
cache then you must destroy it and then create with a new configuration.
I guess values of different types in the same cache are a reason of your
issue.
BR,
Andrei
7/16/2020 4:41 PM, xingjl6280 пишет:
hi team,
Please kindly advise.
Below is my code and exception.
Btw, if I use ScanQuery<String, Object> and List, no error.
Something wrong with classloader? the normal cache put and get work well for
my class, data could be deserialised to my class automatically.
thank you
My code:
*******************************************************************************
cache.put(ProjectCacheConst.STATION_PREFIX+"1", new StationDto());
cache.put(ProjectCacheConst.STATION_PREFIX+"2", new StationDto());
cache.put(ProjectCacheConst.STATION_PREFIX+"3", new StationDto());
ScanQuery<String, StationDto> scanQuery = new ScanQuery<>(
(k, v) -> k.startsWith(ProjectCacheConst.STATION_PREFIX) &&
nonNull(v));
List<StationDto> list = getCache(projectCode).query(scanQuery,
Cache.Entry::getValue).getAll();
*******************************************************************************
Exception:
org.apache.ignite.IgniteException: class java.util.ArrayList cannot be cast
to class com.hh.sd.rtms.h_dto.map.StationDto (java.util.ArrayList is in
module java.base of loader 'bootstrap'; com.hh.sd.rtms.h_dto.map.StationDto
is in unnamed module of loader
org.apache.catalina.loader.ParallelWebappClassLoader @597bc1c6)
at
org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager$InternalScanFilter.apply(GridCacheQueryManager.java:3232)
~[ignite-core-2.8.1.jar:2.8.1]
at
org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager$ScanQueryIterator.advance(GridCacheQueryManager.java:3108)
~[ignite-core-2.8.1.jar:2.8.1]
at
org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager$ScanQueryIterator.onHasNext(GridCacheQueryManager.java:2997)
~[ignite-core-2.8.1.jar:2.8.1]
at
org.apache.ignite.internal.util.GridCloseableIteratorAdapter.hasNextX(GridCloseableIteratorAdapter.java:53)
~[ignite-core-2.8.1.jar:2.8.1]
at
org.apache.ignite.internal.util.lang.GridIteratorAdapter.hasNext(GridIteratorAdapter.java:45)
~[ignite-core-2.8.1.jar:2.8.1]
at
org.apache.ignite.internal.processors.cache.QueryCursorImpl.getAll(QueryCursorImpl.java:123)
~[ignite-core-2.8.1.jar:2.8.1]
at
com.hh.sd.rtms.f_data_service.ProjectCacheServiceBean.getAllStations(ProjectCacheServiceBean.java:166)
~[rtms-core-0.1-SNAPSHOT.jar:na]
at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
Method) ~[na:na]
at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
~[na:na]
at
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at
org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:88)
~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/