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

Moderator: admin

Post Reply
renatumb
Posts: 46
Joined: Mon Apr 08, 2013 7:55 pm
Contact:

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

Post by renatumb » Sun Mar 02, 2014 11:48 pm

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.

admin
Site Admin
Posts: 8239
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin » Mon Mar 03, 2014 12:30 am

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.

himaiMinh
Posts: 358
Joined: Fri Nov 29, 2013 8:26 pm
Contact:

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

Post by himaiMinh » Fri Jun 12, 2015 6:00 pm

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.

admin
Site Admin
Posts: 8239
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin » Sat Jun 13, 2015 1:50 am

Could you please point me to the spec where it says unchecked application exception is allowed?
thank you,
Paul.
If you like our products and services, please help us by posting your review here.

himaiMinh
Posts: 358
Joined: Fri Nov 29, 2013 8:26 pm
Contact:

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

Post by himaiMinh » Sat Jun 13, 2015 10:33 am

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.

admin
Site Admin
Posts: 8239
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin » Sat Jun 13, 2015 8:50 pm

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.
If you like our products and services, please help us by posting your review here.

dfigueira
Posts: 15
Joined: Thu May 05, 2016 2:50 am
Contact:

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

Post by dfigueira » Sun Dec 10, 2017 5:20 pm

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.

admin
Site Admin
Posts: 8239
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin » Sun Dec 10, 2017 11:41 pm

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 you like our products and services, please help us by posting your review here.

dfigueira
Posts: 15
Joined: Thu May 05, 2016 2:50 am
Contact:

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

Post by dfigueira » Fri Dec 15, 2017 4:14 am

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

admin
Site Admin
Posts: 8239
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin » Fri Dec 15, 2017 10:12 pm

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.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests