File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes Interceptors invocation sequence? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Interceptors invocation sequence?" Watch "Interceptors invocation sequence?" New topic

Interceptors invocation sequence?

Alejandro Dominguez

Joined: Jun 01, 2007
Posts: 28
Hi ranchers,
I was trying out some features of the EJB Interceptors and came to a strange behavior:

Statefull session bean defines class interceptor.
Upon calling a method, first is fired the class interceptor, and then the method itself (this is normal).
Console output:

Once I added @PostConstruct to the session bean and to the ClassInterceptor I got the following (normal) behavior:

Now for the weird part: I add a @PostConstruct method in the MethodInterceptor, which is assigned to a *totally* different method from the one being called in the session bean, and I get the following (non-normal?) behavior:

No interceptors are defined in ejb-jar.xml

My Bean code:

ClassInterceptor (MethodInterceptor is identical, just a different .java)

The client:

My question is: why is @PostConstruct on the MethodInterceptor called? It's associated with a method that is not even called at all (demostrated by it's @AroundInvoke method non being called).

Any ideas?



Edited: forgot to add: using JBoss 4.0.5
[ June 06, 2007: Message edited by: Alejandro Dominguez ]

Alejandro<br /> <br />SCJP 5 (SAI)
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

It kind of reminds me of the joke.

Man goes into the doctor's office and raises his hand and arm above his head and says "Doctor it hurts when I do this". Doctor says, "Then don't do that"


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Interceptors invocation sequence?
It's not a secret anymore!