SqlPredicate and ClassNotFoundException

134 views
Skip to first unread message

Altuğ Bilgin Altıntaş

unread,
Oct 25, 2010, 8:33:23 AM10/25/10
to haze...@googlegroups.com
Hi all;

My Hazelcast version : 1.9.0
All my domain objects are Serializable

Here is the  SqlPredicate code

1- IMap map = Hazelcast.getMap("vehicles"); // gets all vehicles, good
2-  Set<Vehicle> employees = (Set<Vehicle>) map.values(new SqlPredicate("bodyNo ="+bodyNo)); // bad


At line 2 it gives below error :

25-Oct-2010 15:20:02 com.hazelcast.nio.Serializer
SEVERE: com.jtpd.tme.mab.pms.model.Vehicle
java.lang.ClassNotFoundException: com.jtpd.tme.mab.pms.model.Vehicle
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at com.hazelcast.nio.Serializer.classForName(Serializer.java:105)
        at com.hazelcast.nio.Serializer.classForName(Serializer.java:84)
        at com.hazelcast.nio.Serializer$1.resolveClass(Serializer.java:304)
        at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
        at java.io.ObjectInputStream.readClassDesc(Unknown Source)
        at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
        at java.io.ObjectInputStream.readObject0(Unknown Source)
        at java.io.ObjectInputStream.readUnshared(Unknown Source)
        at com.hazelcast.nio.Serializer$ObjectSerializer.readNormal(Serializer.j
ava:351)
        at com.hazelcast.nio.Serializer$ObjectSerializer.read(Serializer.java:32
0)
        at com.hazelcast.nio.Serializer.readObject(Serializer.java:155)
        at com.hazelcast.impl.ThreadContext.toObject(ThreadContext.java:85)
        at com.hazelcast.nio.IOUtil.toObject(IOUtil.java:86)
        at com.hazelcast.impl.RecordEntry.getValue(RecordEntry.java:49)
        at com.hazelcast.query.Predicates$GetExpressionImpl.doGetValue(Predicate
s.java:717)
        at com.hazelcast.query.Predicates$GetExpressionImpl.getValue(Predicates.
java:711)
        at com.hazelcast.query.Predicates$EqualPredicate.apply(Predicates.java:3
95)
        at com.hazelcast.query.SqlPredicate.apply(SqlPredicate.java:43)
        at com.hazelcast.impl.ConcurrentMapManager$QueryOperationHandler.createR
esultPairs(ConcurrentMapManager.java:2000)
        at com.hazelcast.impl.ConcurrentMapManager$QueryOperationHandler$QueryTa
sk.run(ConcurrentMapManager.java:1969)
        at com.hazelcast.impl.executor.ParallelExecutorService$ParallelExecutorI
mpl$ExecutionSegment.run(ParallelExecutorService.java:135)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source
)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
25-Oct-2010 15:20:02 com.hazelcast.impl.ConcurrentMapManager
SEVERE: [dev] Request{name='c:vehicles',CONCURRENT_MAP_ITERATE_VALUES, redoCount
='0', lockThreadId='5'}
java.lang.RuntimeException: java.lang.ClassNotFoundException: com.jtpd.tme.mab
.pms.model.Vehicle
        at com.hazelcast.nio.Serializer.readObject(Serializer.java:162)
        at com.hazelcast.impl.ThreadContext.toObject(ThreadContext.java:85)
        at com.hazelcast.nio.IOUtil.toObject(IOUtil.java:86)
        at com.hazelcast.impl.RecordEntry.getValue(RecordEntry.java:49)
        at com.hazelcast.query.Predicates$GetExpressionImpl.doGetValue(Predicate
s.java:717)
        at com.hazelcast.query.Predicates$GetExpressionImpl.getValue(Predicates.
java:711)
        at com.hazelcast.query.Predicates$EqualPredicate.apply(Predicates.java:3
95)
        at com.hazelcast.query.SqlPredicate.apply(SqlPredicate.java:43)
        at com.hazelcast.impl.ConcurrentMapManager$QueryOperationHandler.createR
esultPairs(ConcurrentMapManager.java:2000)
        at com.hazelcast.impl.ConcurrentMapManager$QueryOperationHandler$QueryTa
sk.run(ConcurrentMapManager.java:1969)
        at com.hazelcast.impl.executor.ParallelExecutorService$ParallelExecutorI
mpl$ExecutionSegment.run(ParallelExecutorService.java:135)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source
)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.jtpd.tme.mab.pms.model.Vehicl
e
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at com.hazelcast.nio.Serializer.classForName(Serializer.java:105)
        at com.hazelcast.nio.Serializer.classForName(Serializer.java:84)
        at com.hazelcast.nio.Serializer$1.resolveClass(Serializer.java:304)
        at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
        at java.io.ObjectInputStream.readClassDesc(Unknown Source)
        at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
        at java.io.ObjectInputStream.readObject0(Unknown Source)
        at java.io.ObjectInputStream.readUnshared(Unknown Source)
        at com.hazelcast.nio.Serializer$ObjectSerializer.readNormal(Serializer.j
ava:351)
        at com.hazelcast.nio.Serializer$ObjectSerializer.read(Serializer.java:32
0)
        at com.hazelcast.nio.Serializer.readObject(Serializer.java:155)
        ... 13 more

--------------------------

Any suggestions ?

Thanks.


tomislav

unread,
Oct 25, 2010, 1:48:34 PM10/25/10
to Hazelcast
Do you have

com.jtpd.tme.mab.pms.model.Vehicle

in Classpath of the jvm that has thrown CNFE ?

Altuğ Bilgin Altıntaş

unread,
Oct 26, 2010, 2:56:10 AM10/26/10
to haze...@googlegroups.com
You're right; every node in the data grid has to know com.jtpd.tme.mab.pms.model.Vehicle. Good point.

Thanks.

2010/10/25 tomislav <jomo...@gmail.com>
--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To post to this group, send email to haze...@googlegroups.com.
To unsubscribe from this group, send email to hazelcast+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/hazelcast?hl=en.


kumar.m...@gmail.com

unread,
Mar 4, 2015, 11:48:55 AM3/4/15
to haze...@googlegroups.com, alt...@gmail.com
How did you solve this problem ? 

Manish Kumar

unread,
Mar 9, 2015, 5:31:42 PM3/9/15
to haze...@googlegroups.com
I found the reason behind this problem. Since we are using vertx, when vertx app starts, it also start Hazelcast and classloader provided to Hazelcast is system-class-loader (/vertx_installation/lib), and that's the reason when we ran SQLPredicate, it runs in its own thread as part of Hazelcast, and thus throws ClassNotFoundException (even though classes are present in vertx_installation/mods/my-application/dto)

We decided to not use SQLPredicate because we didn't want to put out domain/dto classes in system lib.

As long as your system class loader has access to those classes(dto/pojo whatever), you must be able to fix this problem.

--
You received this message because you are subscribed to a topic in the Google Groups "Hazelcast" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/hazelcast/Nol3g-D4R10/unsubscribe.
To unsubscribe from this group and all its topics, send an email to hazelcast+...@googlegroups.com.

To post to this group, send email to haze...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages