Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@Asynchronous private method in EJB

I have an asynchronous method in my EJB singleton that's called from another method in the same class. I already know that I can't call the asynchronous method directly, I have to obtain an EJB proxy. The problem is, I don't want the asynchronous method to be visible outside the class; but when I make it private, it's not executed asynchronously. (I'm using Glassfish v3.)

The javadocs don't say anything about the required access level. So should this be considered a bug in Glassfish?

like image 977
Mike Baranczak Avatar asked Feb 27 '26 19:02

Mike Baranczak


1 Answers

method annotation cannot be used in private methods. When Glassfish is compiling your EJB it will basically convert your annotation into a piece of code that will surround your code in a proxy. If your method is private it will bypass the proxy Glassfish created... So, in your case I suggest to create a new EJB with your asynchronous method in inject it in your current EJB

like image 125
Plínio Pantaleão Avatar answered Mar 01 '26 10:03

Plínio Pantaleão



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!