[jira] [Commented] (IGNITE-5424) GridServiceProxy does not unwraps exception message from InvocationTargetException
[ https://issues.apache.org/jira/browse/IGNITE-5424?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16040303#comment-16040303 ] Ben commented on IGNITE-5424: - See https://issues.apache.org/jira/browse/IGNITE-4298 > GridServiceProxy does not unwraps exception message from > InvocationTargetException > -- > > Key: IGNITE-5424 > URL: https://issues.apache.org/jira/browse/IGNITE-5424 > Project: Ignite > Issue Type: Bug > Components: managed services >Affects Versions: 2.1 >Reporter: Dmitry Karachentsev >Assignee: Dmitry Karachentsev > Fix For: 2.2 > > > Instead of correct message 'null' passed. > {noformat} > class org.apache.ignite.IgniteException: null > at > org.apache.ignite.internal.util.IgniteUtils.convertException(IgniteUtils.java:957) > at > org.apache.ignite.internal.processors.service.GridServiceProxy.invokeMethod(GridServiceProxy.java:208) > at > org.apache.ignite.internal.processors.service.GridServiceProxy$ProxyInvocationHandler.invoke(GridServiceProxy.java:356) > at org.apache.ignite.internal.processors.service.$Proxy25.go(Unknown > Source) > at > org.apache.ignite.internal.processors.service.GridServiceProcessorProxySelfTest.testException(GridServiceProcessorProxySelfTest.java:78) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:498) > at junit.framework.TestCase.runTest(TestCase.java:176) > at > org.apache.ignite.testframework.junits.GridAbstractTest.runTestInternal(GridAbstractTest.java:1979) > at > org.apache.ignite.testframework.junits.GridAbstractTest.access$000(GridAbstractTest.java:130) > at > org.apache.ignite.testframework.junits.GridAbstractTest$5.run(GridAbstractTest.java:1894) > at java.lang.Thread.run(Thread.java:745) > Caused by: class org.apache.ignite.IgniteCheckedException: null > at > org.apache.ignite.internal.util.IgniteUtils.cast(IgniteUtils.java:7262) > at > org.apache.ignite.internal.util.future.GridFutureAdapter.resolve(GridFutureAdapter.java:258) > at > org.apache.ignite.internal.util.future.GridFutureAdapter.get0(GridFutureAdapter.java:189) > at > org.apache.ignite.internal.util.future.GridFutureAdapter.get(GridFutureAdapter.java:139) > at > org.apache.ignite.internal.processors.service.GridServiceProxy.invokeMethod(GridServiceProxy.java:197) > ... 12 more > Caused by: java.lang.reflect.InvocationTargetException > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:498) > at > org.apache.ignite.internal.processors.service.GridServiceProxy$ServiceProxyCallable.call(GridServiceProxy.java:417) > at > org.apache.ignite.internal.processors.closure.GridClosureProcessor$C2.execute(GridClosureProcessor.java:1847) > at > org.apache.ignite.internal.processors.job.GridJobWorker$2.call(GridJobWorker.java:566) > at > org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:6641) > at > org.apache.ignite.internal.processors.job.GridJobWorker.execute0(GridJobWorker.java:560) > at > org.apache.ignite.internal.processors.job.GridJobWorker.body(GridJobWorker.java:489) > at > org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110) > at > org.apache.ignite.internal.processors.job.GridJobProcessor.processJobExecuteRequest(GridJobProcessor.java:1180) > at > org.apache.ignite.internal.processors.job.GridJobProcessor$JobExecutionListener.onMessage(GridJobProcessor.java:1907) > at > org.apache.ignite.internal.managers.communication.GridIoManager.invokeListener(GridIoManager.java:1550) > at > org.apache.ignite.internal.managers.communication.GridIoManager.processRegularMessage0(GridIoManager.java:1178) > at > org.apache.ignite.internal.managers.communication.GridIoManager.access$4200(GridIoManager.java:124) > at > org.apache.ignite.internal.managers.communication.GridIoManager$9.run(GridIoManager.java:1095) > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) > ... 1 more > Caused by: java.lang.Exception: Test exception > at >
[jira] [Commented] (IGNITE-4298) User exceptions cause IgniteException if Ignite services are deployed separately
[ https://issues.apache.org/jira/browse/IGNITE-4298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15692902#comment-15692902 ] Ben commented on IGNITE-4298: - Looks like this was already reported here: IGNITE-4235 > User exceptions cause IgniteException if Ignite services are deployed > separately > > > Key: IGNITE-4298 > URL: https://issues.apache.org/jira/browse/IGNITE-4298 > Project: Ignite > Issue Type: Bug >Affects Versions: 1.7 >Reporter: Ben > > 2 services, Service A and Service B, are deployed and restricted to > individual nodes. If A calls a method of B thru the service proxy and a user > exception is thrown inside that method, then an IgniteException is thrown due > to an InvocationTargetException. See code below for a reproducable example. > {code:title=MyUserException.java|borderStyle=solid} > package com.example.testing; > public class MyUserException extends Throwable {} > {code} > {code:title=MyCounterService.java|borderStyle=solid} > package com.example.testing; > public interface MyCounterService { > int increment() throws MyUserException; > } > {code} > Note this error condition in the deployment of the two services: > {{ignite.cluster().forYoungest()}} > {code:title=MyCounterServiceImpl.java|borderStyle=solid} > package com.example.testing; > import org.apache.ignite.Ignite; > import org.apache.ignite.IgniteServices; > import org.apache.ignite.Ignition; > import org.apache.ignite.resources.IgniteInstanceResource; > import org.apache.ignite.services.Service; > import org.apache.ignite.services.ServiceContext; > public class MyCounterServiceImpl implements MyCounterService, Service { > @IgniteInstanceResource > private Ignite ignite; > private int value = 0; > public int increment() throws MyUserException { > if ((value % 2) == 0) { > throw new MyUserException(); > } else { > value++; > } > return value; > } > public static void main(String [] args) { > Ignite ignite = Ignition.start(); > IgniteServices svcs = ignite.services(ignite.cluster().forYoungest()); > svcs.deployNodeSingleton("MyCounterService", new > MyCounterServiceImpl()); > } > @Override > public void cancel(ServiceContext ctx) { > System.out.println("Service cancelled"); > } > @Override > public void init(ServiceContext ctx) throws Exception { > System.out.println("Service initialized"); > } > @Override > public void execute(ServiceContext ctx) throws Exception { > System.out.println("Service running"); > } > } > {code} > {code:title=MyCallerService.java|borderStyle=solid} > package com.example.testing; > import org.apache.ignite.Ignite; > import org.apache.ignite.IgniteException; > import org.apache.ignite.Ignition; > import org.apache.ignite.resources.IgniteInstanceResource; > import org.apache.ignite.services.Service; > import org.apache.ignite.services.ServiceContext; > public class MyCallerService implements Service { > @IgniteInstanceResource > private Ignite ignite; > private Boolean stopped; > public void run() { > stopped = false; > MyCounterService service = > ignite.services().serviceProxy("MyCounterService", MyCounterService.class, > false); > while (!stopped) > { > try { > Thread.sleep(500); > service.increment(); > } catch (MyUserException e) { > System.out.println("Got exception"); > //e.printStackTrace(); > } catch (InterruptedException e) { > //e.printStackTrace(); > } > catch (IgniteException e) { > System.out.println("Got critial exception"); > // would print the actual user exception > //e.getCause().getCause().getCause().printStackTrace(); > break; > } > } > } > public static void main(String [] args) { > Ignite ignite = Ignition.start(); > > ignite.services(ignite.cluster().forYoungest()).deployNodeSingleton("MyCallerService", > new MyCallerService()); > } > @Override > public void cancel(ServiceContext ctx) { > stopped = true; > } > @Override > public void init(ServiceContext ctx) throws Exception { > } > @Override > public void execute(ServiceContext ctx) throws Exception { > run(); > } > } > {code} > {code:title=Output of MyCounterServiceImpl|borderStyle=solid} > [18:23:23] Ignite node started OK (id=c82df19c) > [18:23:23] Topology snapshot [ver=1, servers=1, clients=0, CPUs=4, heap=3.5GB] > Service initialized > Service running > [18:23:27] Topology snapshot [ver=2,
[jira] [Created] (IGNITE-4298) User exceptions cause IgniteException if Ignite services are deployed separately
Ben created IGNITE-4298: --- Summary: User exceptions cause IgniteException if Ignite services are deployed separately Key: IGNITE-4298 URL: https://issues.apache.org/jira/browse/IGNITE-4298 Project: Ignite Issue Type: Bug Affects Versions: 1.7 Reporter: Ben 2 services, Service A and Service B, are deployed and restricted to individual nodes. If A calls a method of B thru the service proxy and a user exception is thrown inside that method, then an IgniteException is thrown due to an InvocationTargetException. See code below for a reproducable example. {code:title=MyUserException.java|borderStyle=solid} package com.example.testing; public class MyUserException extends Throwable {} {code} {code:title=MyCounterService.java|borderStyle=solid} package com.example.testing; public interface MyCounterService { int increment() throws MyUserException; } {code} Note this error condition in the deployment of the two services: {{ignite.cluster().forYoungest()}} {code:title=MyCounterServiceImpl.java|borderStyle=solid} package com.example.testing; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteServices; import org.apache.ignite.Ignition; import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.services.Service; import org.apache.ignite.services.ServiceContext; public class MyCounterServiceImpl implements MyCounterService, Service { @IgniteInstanceResource private Ignite ignite; private int value = 0; public int increment() throws MyUserException { if ((value % 2) == 0) { throw new MyUserException(); } else { value++; } return value; } public static void main(String [] args) { Ignite ignite = Ignition.start(); IgniteServices svcs = ignite.services(ignite.cluster().forYoungest()); svcs.deployNodeSingleton("MyCounterService", new MyCounterServiceImpl()); } @Override public void cancel(ServiceContext ctx) { System.out.println("Service cancelled"); } @Override public void init(ServiceContext ctx) throws Exception { System.out.println("Service initialized"); } @Override public void execute(ServiceContext ctx) throws Exception { System.out.println("Service running"); } } {code} {code:title=MyCallerService.java|borderStyle=solid} package com.example.testing; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteException; import org.apache.ignite.Ignition; import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.services.Service; import org.apache.ignite.services.ServiceContext; public class MyCallerService implements Service { @IgniteInstanceResource private Ignite ignite; private Boolean stopped; public void run() { stopped = false; MyCounterService service = ignite.services().serviceProxy("MyCounterService", MyCounterService.class, false); while (!stopped) { try { Thread.sleep(500); service.increment(); } catch (MyUserException e) { System.out.println("Got exception"); //e.printStackTrace(); } catch (InterruptedException e) { //e.printStackTrace(); } catch (IgniteException e) { System.out.println("Got critial exception"); // would print the actual user exception //e.getCause().getCause().getCause().printStackTrace(); break; } } } public static void main(String [] args) { Ignite ignite = Ignition.start(); ignite.services(ignite.cluster().forYoungest()).deployNodeSingleton("MyCallerService", new MyCallerService()); } @Override public void cancel(ServiceContext ctx) { stopped = true; } @Override public void init(ServiceContext ctx) throws Exception { } @Override public void execute(ServiceContext ctx) throws Exception { run(); } } {code} {code:title=Output of MyCounterServiceImpl|borderStyle=solid} [18:23:23] Ignite node started OK (id=c82df19c) [18:23:23] Topology snapshot [ver=1, servers=1, clients=0, CPUs=4, heap=3.5GB] Service initialized Service running [18:23:27] Topology snapshot [ver=2, servers=2, clients=0, CPUs=4, heap=7.0GB] Nov 17, 2016 6:23:28 PM org.apache.ignite.logger.java.JavaLogger error SCHWERWIEGEND: Failed to execute job [jobId=82580537851-3c0a354f-69b5-496c-af10-ee789a5387c3, ses=GridJobSessionImpl [ses=GridTaskSessionImpl [taskName=o.a.i.i.processors.service.GridServiceProxy$ServiceProxyCallable, dep=LocalDeployment [super=GridDeployment [ts=1479403401422, depMode=SHARED, clsLdr=sun.misc.Launcher$AppClassLoader@1d44bcfa,