[jboss-user] [JBoss Portal] - session/transction mandatory when calling UserModule/RoleMod

je.a.le do-not-reply at jboss.com
Fri Feb 29 08:48:48 EST 2008


I only need read only operations like getting list of role, user, etc...
I notice that in order for a "MBeanProxy" to works, the call must be done inside a session (ok) but into a transaction too (?)

here a working code :

  | Session session = null;
  | Transaction t = null;
  | 	try {
  | 	    SessionFactory identitySessionFactory = (SessionFactory) new InitialContext().lookup("java:/portal/IdentitySessionFactory");
  | 	    session = identitySessionFactory.openSession();
  | 	    t = session.beginTransaction();
  | 
  | 	    MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
  | 	    RoleModule roleModule = (RoleModule) MBeanProxy.get(RoleModule.class,
  |                 new ObjectName("portal:service=Module,type=Role"), mbeanServer);
  | 
  | 	    Set s = roleModule.findRoles();
  | 	    Iterator it = s.iterator();
  | 	    while (it.hasNext()) {
  |                 // just dump role for the test
  | 		System.out.println("roles : " + it.next());
  | 	    }
  | 	} catch (Exception ex) {
  | 	    ex.printStackTrace();
  | 	} finally {
  | 	    if (t != null) {t.rollback(); }
  | 	    if (session != null) {session.close();}
  | 	}
  | 

It's strange to start a transaction and always call a roolback !?!
Am I actually making the request right !???

My code will not be call from a protlet, mostly servlet/dwr.
anyway adding a trans-attribute to portlet.xml doesn't work for me.

  | <transaction>
  | 	<trans-attribute>Required</trans-attribute>
  | </transaction>
  | 

Thanks


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4133226#4133226

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4133226



More information about the jboss-user mailing list