Hello Ioannis,
I found where the issue occurs. It occurs when I try and execute a predicate
on a class I defined. Here is the sample code I used to reproduce the
problem:
My custom class:
public class PredTester implements DataSerializable {
private static final long serialVersionUID = -1359492685240522455L;
private String myvalue;
public PredTester(String value) {
this.myvalue = value;
}
@Override
public void writeData(DataOutput out) throws IOException {
out.writeUTF(myvalue);
}
public String getMyvalue() {
return this.myvalue;
}
@Override
public void readData(DataInput in) throws IOException {
this.myvalue = in.readUTF();
}
}
My activator:
public class Activator implements BundleActivator {
private volatile HazelcastInstance instance = null;
private volatile Thread myThread = null;
private volatile IMap<String,PredTester> myMap = null;
@Override
public void start(BundleContext context) throws Exception {
ClassLoader classLoader =
Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
ServiceReference reference =
context.getServiceReference("com.hazelcast.core.HazelcastInstance");
instance = (HazelcastInstance) context.getService(reference);
context.ungetService(reference);
try {
myMap = instance.getMap("fred-osgi");
myMap.addIndex("myvalue", true);
myMap.put("test1", new PredTester("belt"));
EntryObject e = new PredicateBuilder().getEntryObject();
@SuppressWarnings("unchecked")
Predicate<String,PredTester> predicate =
e.get("myvalue").equal("belt");
Set<Map.Entry<String,PredTester>> entrySet =
myMap.entrySet(predicate);
logger.info("Entries returned = {}",entrySet.size()); << I
believe it
fails here
} catch (Exception ex) {
ex.printStackTrace();
}
Thread.currentThread().setContextClassLoader(classLoader);
}
The following exception is thrown, whether I use an index or not (I thought
using an index may stop Hazelcast needing to deserialize to check for a
match):
21:01:16,037 | ERROR | .cached.thread-1 | AbstractSerializer |
dardLoggerFactory$StandardLogger 58 | - - | Problem reading
DataSerializable class : PredTester, exception:
java.lang.ClassNotFoundException: PredTester not found from bundle
[org.apache.karaf.cellar.hazelcast]
java.io.IOException: Problem reading DataSerializable class :
com.antennasoftware.hazelcasttest.PredTester, exception:
java.lang.ClassNotFoundException:
com.antennasoftware.hazelcasttest.PredTester not found from bundle
[org.apache.karaf.cellar.hazelcast]
at
com.hazelcast.nio.Serializer$DataSerializer.read(Serializer.java:98)[135:hazelcast:1.9.3]
at
com.hazelcast.nio.Serializer$DataSerializer.read(Serializer.java:69)[135:hazelcast:1.9.3]
at
com.hazelcast.nio.AbstractSerializer.toObject(AbstractSerializer.java:105)[135:hazelcast:1.9.3]
at
com.hazelcast.nio.AbstractSerializer.toObject(AbstractSerializer.java:135)[135:hazelcast:1.9.3]
at
com.hazelcast.nio.Serializer.readObject(Serializer.java:62)[135:hazelcast:1.9.3]
at
com.hazelcast.impl.ThreadContext.toObject(ThreadContext.java:113)[135:hazelcast:1.9.3]
at
com.hazelcast.nio.IOUtil.toObject(IOUtil.java:149)[135:hazelcast:1.9.3]
at
com.hazelcast.impl.Record.getValue(Record.java:143)[135:hazelcast:1.9.3]
at
com.hazelcast.query.Predicates$GetExpressionImpl.doGetValue(Predicates.java:842)[135:hazelcast:1.9.3]
at
com.hazelcast.query.Predicates$GetExpressionImpl.getValue(Predicates.java:836)[135:hazelcast:1.9.3]
at
com.hazelcast.query.Predicates$EqualPredicate.apply(Predicates.java:450)[135:hazelcast:1.9.3]
at
com.hazelcast.query.PredicateBuilder.apply(PredicateBuilder.java:32)[135:hazelcast:1.9.3]
at
com.hazelcast.impl.ConcurrentMapManager$QueryOperationHandler.createResultPairs(ConcurrentMapManager.java:2658)[135:hazelcast:1.9.3]
at
com.hazelcast.impl.ConcurrentMapManager$QueryOperationHandler$QueryTask.run(ConcurrentMapManager.java:2627)[135:hazelcast:1.9.3]
at
com.hazelcast.impl.executor.ParallelExecutorService$ParallelExecutorImpl$ExecutionSegment.run(ParallelExecutorService.java:179)[135:hazelcast:1.9.3]
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)[:1.6.0_26]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)[:1.6.0_26]
at java.lang.Thread.run(Thread.java:680)[:1.6.0_26]
I guess this makes it difficult to use Hazelcast predicates in OSGi (for
now).
thanks again,
Gareth
--
View this message in context:
http://karaf.922171.n3.nabble.com/Cellar-And-Hazelcast-Questions-tp3184320p3202047.html
Sent from the Karaf - User mailing list archive at Nabble.com.