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=E296A2B1C1633F424959E377C8838B32?page=all 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 _______________________________________________ jboss-user mailing list [email protected] https://lists.jboss.org/mailman/listinfo/jboss-user
