Search code examples
cachingserviceignitegridgain

Fail to deploy service using thick client


I'm trying to deploy a simple service using a thick client, I use kubernetes job to launch a thick client, and then use ignite instance to deploy:

private void deployService() {
    ServiceConfiguration serviceCfg = new ServiceConfiguration();

    serviceCfg.setName("simpleService");
    serviceCfg.setMaxPerNodeCount(1);
    serviceCfg.setTotalCount(1);
    serviceCfg.setService(new SimpleServiceImpl());
    ignite.services().deploy(serviceCfg);
}

but I got the following error:

SEVERE: Failed to initialize service (service will not be deployed): simpleService

class org.apache.ignite.IgniteCheckedException: com.example.ignite_springcloud.model.ignite_service.SimpleServiceImpl at
org.apache.ignite.internal.util.IgniteUtils.unmarshal(IgniteUtils.java:11026) at org.apache.ignite.internal.processors.service.GridServiceProcessor.copyAndInject(GridServiceProcessor.java:1381) at 
org.apache.ignite.internal.processors.service.GridServiceProcessor.redeploy(GridServiceProcessor.java:1302) at 
org.apache.ignite.internal.processors.service.GridServiceProcessor.processAssignment(GridServiceProcessor.java:1931) at 
org.apache.ignite.internal.processors.service.GridServiceProcessor.onSystemCacheUpdated(GridServiceProcessor.java:1555) at 
org.apache.ignite.internal.processors.service.GridServiceProcessor.access$300(GridServiceProcessor.java:133) at 
org.apache.ignite.internal.processors.service.GridServiceProcessor$ServiceEntriesListener$1.run0(GridServiceProcessor.java:1537) at 
org.apache.ignite.internal.processors.service.GridServiceProcessor$DepRunnable.run(GridServiceProcessor.java:2007) at 
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at 
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:829) Caused by: class org.apache.ignite.binary.BinaryInvalidTypeException: com.example.ignite_springcloud.model.ignite_service.SimpleServiceImpl at 
org.apache.ignite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:697) at 
org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize0(BinaryReaderExImpl.java:1765) at 
org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize(BinaryReaderExImpl.java:1724) at 
org.apache.ignite.internal.binary.GridBinaryMarshaller.deserialize(GridBinaryMarshaller.java:318) at 
org.apache.ignite.internal.binary.GridBinaryMarshaller.deserialize(GridBinaryMarshaller.java:303) at 
org.apache.ignite.internal.binary.BinaryMarshaller.unmarshal0(BinaryMarshaller.java:100) at 
org.apache.ignite.marshaller.AbstractNodeNameAwareMarshaller.unmarshal(AbstractNodeNameAwareMarshaller.java:80) at 
org.apache.ignite.internal.util.IgniteUtils.unmarshal(IgniteUtils.java:11020) ... 10 more Caused by: 

java.lang.ClassNotFoundException: com.example.ignite_springcloud.model.ignite_service.SimpleServiceImpl at 
java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) at 
java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at 
java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) at 
java.base/java.lang.Class.forName0(Native Method) at 
java.base/java.lang.Class.forName(Class.java:398) at 
org.apache.ignite.internal.util.IgniteUtils.forName(IgniteUtils.java:9503) at 
org.apache.ignite.internal.util.IgniteUtils.forName(IgniteUtils.java:9441) at 
org.apache.ignite.internal.MarshallerContextImpl.getClass(MarshallerContextImpl.java:325) at 
org.apache.ignite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:673) ... 170 more

Also, the service related class and interface are defined together with thick client, and I didn't provide jar or classpath on server nodes, but I set peer class loading for both client and servers:

igniteConfig.setPeerClassLoadingEnabled(true);
igniteConfig.setDeploymentMode(DeploymentMode.CONTINUOUS);

I just wonder if this is the correct way to deploy a service to server. and btw, if I deployed the service through a thick client, then that thick client left the cluster and closed, will the service be accessible and callable by other client nodes?


Solution

  • Peer class loading does not work for Services: https://ignite.apache.org/docs/latest/code-deployment/peer-class-loading

    You have to deploy service classes manually on server nodes.

    if I deployed the service through a thick client, then that thick client left the cluster and closed, will the service be accessible and callable by other client nodes

    Yes.