[Management, JMX/JBoss] - Re: Add method to MDB for jmx/mbean?
by rocken7
So I did the JMX Mbean, and had a hell of a time figuring out how to get to an EntityManager from within the MBean. No resource injection works, why I have no idea, is this a bug?
@PersistenceContext did nothing, @Resource did nothing. No idea how to get that working. The @Management annotation is a mystery as well (but I digress).
Me thinks jboss/redhat need some serious document renewals, the documentation is worse than my GF's sense of direction.
Without the UserTransaction, jboss vomits NullPointer exceptions. All attempts to create the EntityManager using the factory failed as well.
Here is a related jira report:
http://jira.jboss.com/jira/browse/EJBTHREE-665;jsessionid=E296A2B1C1633F4...
This was how I got it to work:
UserTransaction tx = null;
|
| try
| {
| InitialContext ctx = new InitialContext();
| tx = (UserTransaction) ctx.lookup("UserTransaction");
| tx.begin();
|
| EntityManager em = (EntityManager) ctx.lookup("java:/Myxdb");
| Query q = em.createNamedQuery("MyXAdsProp.findByName");
| q.setParameter("name", name);
|
| MyXAdsProp dap = (MyXAdsProp) q.getSingleResult();
| if( dap.getValue() != null && !dap.getValue().equals(value))
| {
| dap.setValue(value);
| }
|
| tx.commit();
| return "OK";
| }
| catch(Exception e)
| {
| if( tx.getStatus() == Status.STATUS_ACTIVE )
| {
| tx.rollback();
| }
|
| e.printStackTrace();
| return new String(e.getMessage());
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4028093#4028093
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4028093
19Â years, 1Â month
[JBossCache] - Re: Memory leak when using JbossCache and JOTM
by atijms
"bstansberry(a)jboss.com" wrote : Does the reference chain from the JOTM object lead through a javax.transaction.Synchronization implementation? For example, org.jboss.cache.interceptors.TxInterceptor$RemoteSynchronizationHandler (or TxInterceptor$LocalSynchronizationHandler)?
|
Yes it does. Just for clarity I'll post the whole reference chain anyway:
| [sticky class] (jprofiler term.)
| |
| class com.sun.corba.se.impl.util.Utility
| |
| com.sun.corba.se.impl.util.IdentityHashtable
| |
| <class>[]
| |
| com.sun.corba.se.impl.util.IdentityHashTableEntry
| |
| org.objectweb.jotm.SubCoordinator
| |
| java.util.Vector
| |
| <class>[]
| |
| org.jboss.cache.interceptors.OrderedSynchronisationHandler
| |
| ...
| |
| org.jboss.cache.interceptors.TxInterceptor$LocalSynchronizationHandler
| |
| org.jboss.cache.TransactionEntry
| |
| ...
| |
| org.jboss.cache.marshall.JBCMethodCall
| |
| <class>[]
| |
| [the object I put into JBossCache]
|
anonymous wrote :
| 2) JOTM is holding a ref to the Synchronization and won't ever release it. That would be a bug in JOTM.
|
This is what is currently happening, as I don't think "for a little while" means atleast a few hours ;)
I'm going to read the link you posted. Meanwhile I'm also reading through JOTM's sourcecode to see if it's anything trivial to fix (but I'm afraid it isn't).
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4028072#4028072
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4028072
19Â years, 1Â month