will be executed too, regardless the return type is void or not."In regularM2void""
About Question enthuware.oce-ejbd.v6.2.406 :
Moderator: admin
-
- Posts: 47
- Joined: Mon Apr 08, 2013 7:55 pm
- Contact:
About Question enthuware.oce-ejbd.v6.2.406 :
I agree with the explanation, but i think it should mention that
-
- Site Admin
- Posts: 10078
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.406 :
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.
If you like our products and services, please help us by posting your review here.
-
- Posts: 358
- Joined: Fri Nov 29, 2013 8:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.406 :
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.
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.
-
- Site Admin
- Posts: 10078
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.406 :
Could you please point me to the spec where it says unchecked application exception is allowed?
thank you,
Paul.
thank you,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 358
- Joined: Fri Nov 29, 2013 8:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.406 :
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 :
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.
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{ ...}
And unchecked exception may or may not be annotated with @ApplicationException.
-
- Site Admin
- Posts: 10078
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.406 :
As per section 4.5.2,
HTH,
Paul.
It is clearly talking about all application exceptions and not just checked ones.An asynchronous method with return type void must not declare any application exceptions.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 21
- Joined: Thu May 05, 2016 2:50 am
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.406 :
Have you tried to run this code?
The asynchronous method call is returning an exception before the method returns.
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.
-
- Site Admin
- Posts: 10078
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.406 :
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.
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.
If you like our products and services, please help us by posting your review here.
-
- Posts: 21
- Joined: Thu May 05, 2016 2:50 am
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.406 :
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
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
-
- Site Admin
- Posts: 10078
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.406 :
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.
An async method with void return type has no way to return an exception to the caller.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 11 guests