ignite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Artem Shutak (JIRA)" <j...@apache.org>
Subject [jira] [Created] (IGNITE-1823) Peer class loading can produce ClassCastException with DeploymentMode.SHARED (default)
Date Fri, 30 Oct 2015 17:00:28 GMT
Artem Shutak created IGNITE-1823:
------------------------------------

             Summary: Peer class loading can produce ClassCastException with DeploymentMode.SHARED
(default)
                 Key: IGNITE-1823
                 URL: https://issues.apache.org/jira/browse/IGNITE-1823
             Project: Ignite
          Issue Type: Bug
            Reporter: Artem Shutak


Peer class loading can produce ClassCastException with DeploymentMode.SHARED (default).

Steps to reproduce.
- Build Ignite under java 7. 
- Run ignite.sh with default configuration and enabled peer class loading under Java 8
- Run Test class under java8
- Run Test class under java8 again. On second run you will get ClassCastException.

Looks like the issue is Ignite use different classloaders for first and second run of Test
(Task class deployed and undeployed each time).

{noformat}
[19:56:03,013][SEVERE][ignite-#18%sys-null%][GridTaskWorker] Failed to obtain remote job result
policy for result from ComputeTask.result(..) method (will fail the whole task): GridJobResultImpl
[job=C2 [], sib=GridJobSiblingImpl [sesId=37a6da9b051-7d576228-e0e4-492c-a325-35ce4fc40ea0,
jobId=47a6da9b051-cadb35ba-9bc8-4f05-b9ce-03344883743f, nodeId=cadb35ba-9bc8-4f05-b9ce-03344883743f,
isJobDone=false], jobCtx=GridJobContextImpl [jobId=47a6da9b051-cadb35ba-9bc8-4f05-b9ce-03344883743f,
timeoutObj=null, attrs={}], node=TcpDiscoveryNode [id=cadb35ba-9bc8-4f05-b9ce-03344883743f,
addrs=[0:0:0:0:0:0:0:1%lo, 127.0.0.1, 192.168.1.159], sockAddrs=[/192.168.1.159:47500, /0:0:0:0:0:0:0:1%lo:47500,
/127.0.0.1:47500, /192.168.1.159:47500], discPort=47500, order=1, intOrder=1, lastExchangeTime=1446224162137,
loc=false, ver=1.5.0#20151029-sha1:91059ba8, isClient=false], ex=class o.a.i.IgniteException:
mypackage.Task cannot be cast to mypackage.Task, hasRes=true, isCancelled=false, isOccupied=true]
class org.apache.ignite.IgniteException: Remote job threw user exception (override or implement
ComputeTask.result(..) method if you would like to have automatic failover for this exception).
	at org.apache.ignite.compute.ComputeTaskAdapter.result(ComputeTaskAdapter.java:101)
	at org.apache.ignite.internal.processors.task.GridTaskWorker$3.apply(GridTaskWorker.java:903)
	at org.apache.ignite.internal.processors.task.GridTaskWorker$3.apply(GridTaskWorker.java:896)
	at org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:6403)
	at org.apache.ignite.internal.processors.task.GridTaskWorker.result(GridTaskWorker.java:896)
	at org.apache.ignite.internal.processors.task.GridTaskWorker.onResponse(GridTaskWorker.java:792)
	at org.apache.ignite.internal.processors.task.GridTaskProcessor.processJobExecuteResponse(GridTaskProcessor.java:995)
	at org.apache.ignite.internal.processors.task.GridTaskProcessor$JobMessageListener.onMessage(GridTaskProcessor.java:1219)
	at org.apache.ignite.internal.managers.communication.GridIoManager.processRegularMessage0(GridIoManager.java:811)
	at org.apache.ignite.internal.managers.communication.GridIoManager.access$1500(GridIoManager.java:106)
	at org.apache.ignite.internal.managers.communication.GridIoManager$5.run(GridIoManager.java:774)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: class org.apache.ignite.IgniteException: mypackage.Task cannot be cast to mypackage.Task
	at org.apache.ignite.internal.processors.closure.GridClosureProcessor$C2.execute(GridClosureProcessor.java:1792)
	at org.apache.ignite.internal.processors.job.GridJobWorker$2.call(GridJobWorker.java:509)
	at org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:6371)
	at org.apache.ignite.internal.processors.job.GridJobWorker.execute0(GridJobWorker.java:503)
	at org.apache.ignite.internal.processors.job.GridJobWorker.body(GridJobWorker.java:456)
	at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
	at org.apache.ignite.internal.processors.job.GridJobProcessor.processJobExecuteRequest(GridJobProcessor.java:1166)
	at org.apache.ignite.internal.processors.job.GridJobProcessor$JobExecutionListener.onMessage(GridJobProcessor.java:1776)
	... 6 more
Caused by: java.lang.ClassCastException: mypackage.Task cannot be cast to mypackage.Task
	at mypackage.Test.lambda$main$cea8297e$1(Test.java:40)
	at org.apache.ignite.internal.processors.closure.GridClosureProcessor$C2.execute(GridClosureProcessor.java:1789)
	... 13 more
[19:56:03] Ignite node stopped OK [uptime=00:00:00:371]
Exception in thread "main" class org.apache.ignite.IgniteException: mypackage.Task cannot
be cast to mypackage.Task
	at org.apache.ignite.internal.util.IgniteUtils.convertException(IgniteUtils.java:881)
	at org.apache.ignite.internal.IgniteComputeImpl.broadcast(IgniteComputeImpl.java:270)
	at mypackage.Test.main(Test.java:28)
Caused by: class org.apache.ignite.IgniteCheckedException: mypackage.Task cannot be cast to
mypackage.Task
	at org.apache.ignite.internal.util.IgniteUtils.cast(IgniteUtils.java:6979)
	at org.apache.ignite.internal.util.future.GridFutureAdapter.get0(GridFutureAdapter.java:166)
	at org.apache.ignite.internal.util.future.GridFutureAdapter.get(GridFutureAdapter.java:115)
	at org.apache.ignite.internal.AsyncSupportAdapter.saveOrGet(AsyncSupportAdapter.java:112)
	at org.apache.ignite.internal.IgniteComputeImpl.broadcast(IgniteComputeImpl.java:267)
	... 1 more
Caused by: java.lang.ClassCastException: mypackage.Task cannot be cast to mypackage.Task
	at mypackage.Test.lambda$main$cea8297e$1(Test.java:40)
	at org.apache.ignite.internal.processors.closure.GridClosureProcessor$C2.execute(GridClosureProcessor.java:1789)
	at org.apache.ignite.internal.processors.job.GridJobWorker$2.call(GridJobWorker.java:509)
	at org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:6371)
	at org.apache.ignite.internal.processors.job.GridJobWorker.execute0(GridJobWorker.java:503)
	at org.apache.ignite.internal.processors.job.GridJobWorker.body(GridJobWorker.java:456)
	at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
	at org.apache.ignite.internal.processors.job.GridJobProcessor.processJobExecuteRequest(GridJobProcessor.java:1166)
	at org.apache.ignite.internal.processors.job.GridJobProcessor$JobExecutionListener.onMessage(GridJobProcessor.java:1776)
	at org.apache.ignite.internal.managers.communication.GridIoManager.processRegularMessage0(GridIoManager.java:811)
	at org.apache.ignite.internal.managers.communication.GridIoManager.access$1500(GridIoManager.java:106)
	at org.apache.ignite.internal.managers.communication.GridIoManager$5.run(GridIoManager.java:774)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
{noformat}
 
Code of Test.
{code}
public class Task implements IgniteCallable<String> {
    private static final long serialVersionUID = 1L;

    @Override
    public String call() throws Exception {
        System.err.println("task called");
        return InetAddress.getLocalHost().getHostName();
    }
}
{code}

{code}
public class Test {
    public static void main(String[] args) {
        final IgniteConfiguration cfg = new IgniteConfiguration();
        cfg.setPeerClassLoadingEnabled(true);
        try (final Ignite ignite = Ignition.start(cfg)) {
            final IgniteQueue<Task> queue = ignite.queue("myTaskQueue", 0, new CollectionConfiguration());
            queue.clear();

            queue.addAll(Collections.nCopies(100, new Task()));

            final IgniteCompute compute = ignite.compute();

            final Collection<Collection<String>> res = compute.broadcast(() ->
{
                Ignite ign = Ignition.ignite();

                final IgniteQueue<Task> q = ign.queue("myTaskQueue", 0, null);

                final Collection<String> results = new ArrayList<>();

                Object task = q.poll();

                ign.log().info(">>>>> Class of task: " + task.getClass());

                for (; task != null; ) {
                    results.add(((Task)task).call());

                    task = q.poll();
                }

                return results;
            });

            System.out.println(res);
        }
    }
}
{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message