You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by MDmitry_ <vp...@mail.ru> on 2019/03/07 08:04:28 UTC
peerClassLoadingEnabled=true but java.lang.ClassNotFoundException
Interface
package ru.service.grid;
import org.apache.ignite.services.Service;
public interface HashService extends Service {
String getHash(String str);
}
Implementation
package ru.service.grid;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.ignite.services.Service;
import org.apache.ignite.services.ServiceContext;
import java.io.Serializable;
public class HashServiceImpl implements HashService {
private static final long serialVersionUID = 3L;
@Override
public void cancel(ServiceContext ctx) {
System.out.println("Service was cancelled: " + ctx.name());
}
@Override
public void init(ServiceContext ctx) throws Exception {
System.out.println("Service was initialized: " + ctx.name());
}
@Override
public void execute(ServiceContext ctx) throws Exception {
System.out.println("Service was executed: " + ctx.name());
}
@Override
public String getHash(String str) {
String hash = DigestUtils.md5Hex(str);
System.out.println("Server: " + hash);
return hash;
}
}
Config
<property name="peerClassLoadingEnabled" value="true"/>
<property name="serviceConfiguration">
<list>
<bean
class="org.apache.ignite.services.ServiceConfiguration">
<property name="service">
<bean class="ru.service.grid.HashServiceImpl"/>
</property>
<property name="totalCount" value="2"/>
<property name="maxPerNodeCount" value="1"/>
</bean>
</list>
</property>
Run
Ignition.start("service.xml")
Error
java.lang.ClassNotFoundException: ru.service.grid.HashServiceImpl
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: peerClassLoadingEnabled=true but java.lang.ClassNotFoundException
Posted by Stephen Darlington <st...@gridgain.com>.
From the documentation (https://apacheignite.readme.io/docs/service-grid):
> Note, that by default it's required to have a Service class in the classpath of all the cluster nodes. Peer class loading (P2P class loading) is not supported for Service Grid
So, generally, you have to deploy a JAR file to each node.
Regards,
Stephen
> On 7 Mar 2019, at 08:04, MDmitry_ <vp...@mail.ru> wrote:
>
> Interface
>
> package ru.service.grid;
>
> import org.apache.ignite.services.Service;
>
> public interface HashService extends Service {
> String getHash(String str);
> }
>
> Implementation
>
> package ru.service.grid;
>
> import org.apache.commons.codec.digest.DigestUtils;
> import org.apache.ignite.services.Service;
> import org.apache.ignite.services.ServiceContext;
>
> import java.io.Serializable;
>
> public class HashServiceImpl implements HashService {
>
> private static final long serialVersionUID = 3L;
>
> @Override
> public void cancel(ServiceContext ctx) {
> System.out.println("Service was cancelled: " + ctx.name());
> }
>
> @Override
> public void init(ServiceContext ctx) throws Exception {
> System.out.println("Service was initialized: " + ctx.name());
> }
>
> @Override
> public void execute(ServiceContext ctx) throws Exception {
> System.out.println("Service was executed: " + ctx.name());
> }
>
> @Override
> public String getHash(String str) {
> String hash = DigestUtils.md5Hex(str);
> System.out.println("Server: " + hash);
> return hash;
> }
> }
>
> Config
>
> <property name="peerClassLoadingEnabled" value="true"/>
>
> <property name="serviceConfiguration">
> <list>
> <bean
> class="org.apache.ignite.services.ServiceConfiguration">
> <property name="service">
> <bean class="ru.service.grid.HashServiceImpl"/>
> </property>
> <property name="totalCount" value="2"/>
> <property name="maxPerNodeCount" value="1"/>
> </bean>
> </list>
> </property>
>
> Run
>
> Ignition.start("service.xml")
>
> Error
>
> java.lang.ClassNotFoundException: ru.service.grid.HashServiceImpl
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/