Page 1 of 1

About Question enthuware.oce-ejbd.v6.2.406 :

Posted: Sun Mar 02, 2014 11:48 pm
by renatumb
I agree with the explanation, but i think it should mention that
"In regularM2void""
will be executed too, regardless the return type is void or not.

Re: About Question enthuware.oce-ejbd.v6.2.406 :

Posted: Mon Mar 03, 2014 12:30 am
by admin
Yes, that code is in the bean method itself so it will be printed. I don't think it is relevant to the question though.

Re: About Question enthuware.oce-ejbd.v6.2.406 :

Posted: Fri Jun 12, 2015 6:00 pm
by himaiMinh
In the explanation, "asynchronous methods with return type void must not declare application exception."
It think it should be "asynchronous methods with return type void must not declare application exception , which is checked exceptions".

I think it is fine for asynchronous to declare application exception, which is unchecked exceptions.

Re: About Question enthuware.oce-ejbd.v6.2.406 :

Posted: Sat Jun 13, 2015 1:50 am
by admin
Could you please point me to the spec where it says unchecked application exception is allowed?
thank you,
Paul.

Re: About Question enthuware.oce-ejbd.v6.2.406 :

Posted: Sat Jun 13, 2015 10:33 am
by himaiMinh
No, the spec does not say asynchronous method can throw RuntimeException annotated with @ApplicationException.

Use question v6.2.402:
it is not the option because it may not declare checked exception :

Code: Select all

 @Asynchronous 
  //This Exception is an application exception for sure.
  public void getItDone() throws Exception{ ...}
But an asynchronous method can to throw unchecked exception (eg. RuntimeException) inside the method. In this situation, the client won't receive it.
And unchecked exception may or may not be annotated with @ApplicationException.

Re: About Question enthuware.oce-ejbd.v6.2.406 :

Posted: Sat Jun 13, 2015 8:50 pm
by admin
As per section 4.5.2,
An asynchronous method with return type void must not declare any application exceptions.
It is clearly talking about all application exceptions and not just checked ones.

HTH,
Paul.

Re: About Question enthuware.oce-ejbd.v6.2.406 :

Posted: Sun Dec 10, 2017 5:20 pm
by dfigueira
Have you tried to run this code?
then once control has returned from the client’s method call no exceptions occurring during the processing of the invocation will be delivered to the client

The asynchronous method call is returning an exception before the method returns.

Re: About Question enthuware.oce-ejbd.v6.2.406 :

Posted: Sun Dec 10, 2017 11:41 pm
by admin
You have quoted the explanation incorrectly. It starts with, "If the asynchronous method has return type void, ...". So you basically missed the critical part. This is as per Section 4.5.5 of EJB 3.1 specification.

If your async method call for a method that returns void is getting an exception then either you are doing something differently or the container is not sticking to the specification.

HTH,
Paul.

Re: About Question enthuware.oce-ejbd.v6.2.406 :

Posted: Fri Dec 15, 2017 4:14 am
by dfigueira
Hi Paul,

So depending on the return type a different behaviour exists?

If it is Future<V> the method returns promptly with a Future<V> and the void requires the method to return and finish correctly? where is the asynchronous part?

I was asking you this because in some test I did, I tried to invoke an asynchronous method which was throwing an exception right before returning and the asynchronous call couldn't be invoked because of that. But I'll try to reproduce this particular case and check the differences more in detail.

Regards,
DF

Re: About Question enthuware.oce-ejbd.v6.2.406 :

Posted: Fri Dec 15, 2017 10:12 pm
by admin
No, the method will return immediately in both the cases. But if the method has a return value, then it is returned later wrapped in a Future object. This Future's get method will throw an ExecutionException if an exception was thrown by the async method.

An async method with void return type has no way to return an exception to the caller.