users@glassfish.java.net

What are the limitations in EJB interceptors and JPA listeners?

From: <glassfish_at_javadesktop.org>
Date: Thu, 12 Jul 2007 20:36:59 PDT

Does anyone have a concise list of what you CAN'T do in an EJB interceptor or JPA listener?

We've been having some REALLY strange JPA, JMS, and transaction problems (GFv2 beta 3), and they seem to be sourced in our Audting JPA Listener.

At least, I should say, the problems go away when we comment out the "meaty" code called by the Listeners.

Now, in the JPA spec, it mentions the things you CAN do in a Listener, such as calling JMS, JDBC, Enterprise Beans, etc.

But it suggests you don't to anything to the Entities relationships or to the Entity Manager.

So, does that include calling a Session Bean that uses the Entity Manager? What if it's in a seperate transaction (i.e. REQUIRES_NEW on the Session Bean).

Seriously, we've been seeing just the weirdest behaviors. Our most recent example, tho I'm not the expert on the auditing code so I can't comment on what it's doing, if you simply create a new Entity, and called em.merge on it, the EM was trying to insert the value twice (it'd get the Sequence once, then call INSERT twice, and then get a primary key exception according to the SQL trace). That just made absolutely no sense. The audit code doesn't have anything to do with the actual entities themselves (it looks at them, but doesn't change them).

Originally we were putting data in the JMS queues (that's what we were doing when I was getting IllegalStateExceptions with my multiple REQUIRE_NEW Session Bean calls), but we were running in to issues there as well. It wasn't clear if it was related to unclosed connections to the JMS system, or not (again, this wasn't my code). But, simply put, when we comment out the main core of our Audit listener code (the actual Listeners remain, they just call empty methods), the system works fine.

So, I'm curious what we can and can't do in Listener code, and perhaps Interceptor code (don't seem to be having problems with those yet, but I figured I'd ask anyway). Because whatever we're doing now is scrambling things up something awful.
[Message sent by forum member 'whartung' (whartung)]

http://forums.java.net/jive/thread.jspa?messageID=226492