I encountered such a strange (at least to me ;) - a jboss beginner) situation. During such a flow: JMX bean invokes service,
and the service invokes dao which uses HibernateTemplate. This fails because hibernate's JtaTransaction class fails, looking for java:comp/UserTransaction. I tried to do such lookup in the jmx bean class just for test, and it is not present there in fact.
But it is present during jmx bean initialization, i.e in its conctructor. I assume it has something to do with class loading issues, bean is created from a thread using different classloader (which involves java:comp namespace isolation requirement) than is later used for normal jmx operation invocation.
I know that normal jndi location for UserTransaction in jboss is "UserTransaction" and that there is a linking done
from comp/UserTRansaction to UserTransaction, I saw such code in AbstractWebDeployer for example. However I assume it is not a
user's task to do such linking, so the question is what could be the raeson of such behavior and how to fix it?
I would appreciate any clarification in this context.
Ah, one more thing, our jmx beans are created using ManagedResource spring annotation.
thanks in advance.
Per the Java EE spec, the server is required to make java:comp/UserTransaction available only for web apps and EJBs. Other components, including JMX, can't rely on it being present in JNDI.