JBoss: 3.2.3 on WindowsXP / Hibernate: 2.11 / Postgres 7.4
Hi all, sorry my english, I'm braziliam and this text was translated with babelfish :-)
I have an problem with Hibernate using MBean solution provided by
http://www.hibernate.org/66.html
The problem is:
The ejbA have a business rule thats call 2 sucessive hibernate methods in ejbB, like this (all ejbs are stateless):
Code:
//in ejbA
EjbB ejbB = null;
public void ejbCreate() {
ejbB = ((EjbBHome) serviceLocator.getService(EjbBHome.JNDI_NAME)).create();
}
public boolean removeActorByID(int id) {
String hql = "from Actor a where a.id = " + id;
ejbB.delete("hql");
if (ejbB.find("hql") == null) {
return true;
}
return false;
}
//in ejbB (This ejb is based on Konstantin Pribluda's Hibernate demo implementation)
public void delete(String query) {
try {
Session session = getSession();
session.delete(query);
session.flush();
session.close();
} catch (Exception e) {
ctx.setRollbackOnly();
}
}
public List find(String query) {
List objs = null;
try {
Session session = getSession();
objs = session.find(query);
session.close();
} catch (Exception e) {
return null;
}
return objs;
}
The error occurs in EjbA when "find" is called after "delete" raise an error (eg Violates FK), calling setRollBackOnly.
The error is "Could not register synchronization with JTA TransactionManager"
I know that this error not is caused by Hibernate (
http://forum.hibernate.org/viewtopic.ph ... +exception), but how I can resolve it? I need to synchronized these ejbs? How?