I've solve it with this code:
public class HibernateWS extends GenericSOAPHandler {
@Override
public boolean handleFault(MessageContext msgContext) {
UserTransaction _tx = null;
try {
if (msgContext.containsKey("hibernateTrx")){
_tx = (UserTransaction)msgContext.get("hibernateTrx");
_tx.rollback();
}
} catch (Exception e) {
Log.error("No se ha podido hacer el rollback", e);
throw new RuntimeException(e);
}
return super.handleFault(msgContext);
}
@Override
protected boolean handleInbound(MessageContext msgContext) {
try {
HibernateUtil.openSession();
UserTransaction _tx = (UserTransaction) new InitialContext()
.lookup("java:comp/UserTransaction");
_tx.begin();
msgContext.put("hibernateTrx", _tx);
} catch (Exception e) {
Log.error("Cogiendo la transacción.", e);
}
return true;
}
@Override
protected boolean handleOutbound(MessageContext msgContext) {
UserTransaction _tx = null;
try {
if (msgContext.containsKey("hibernateTrx")){
_tx = (UserTransaction)msgContext.get("hibernateTrx");
_tx.commit();
}
} catch (Exception e) {
Log.error("Haciendo el commit", e);
try {
if(_tx != null)
_tx.rollback();
} catch (Exception e2) {
Log.error("Haciendo el rollback", e2);
}
throw new RuntimeException(e);
}
return true;
}
}
I use Jboss 4.0.5
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4024642#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...