Hello,
I have the following stateless session bean:
@Stateless
public class UtilityBean implements UtilityRemote
{
@PersistenceContext(unitName="performance_persistence_unit")
EntityManager manager;
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
private void deleteStockItems()
{
System.out.println("Start deleting StockItems");
Query qStockItem = manager.createQuery("delete from StockItem");
int retValue = qStockItem.executeUpdate();
System.out.println("Deleted "+retValue+" rows.");
System.out.println("End deleting StockItems");
}
.., here are similar methods for other entities ...
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void deleteAllData()
{
System.out.println("Start deleting all data in database");
deleteStockItems();
deleteOrderItems();
deleteOrders();
deleteCompanies();
deleteCountries();
System.out.println("End deleting all data in database");
}
@Remove
public void free()
{
}
When I invoke deleteAllData() method from client, I get after 5 minutes warning (only part):
WARN [org.jboss.tm.TransactionImpl] Transaction timed out. status=STATUS_ACTIVE
And when method ends then I obtain exception (only part):
ERROR [org.hibernate.util.JDBCExceptionReporter] Transaction is not active
Solution - change in jboss-service.xml file section of "TransactionManagerService" the value of "TransactionTimeout" from 300 to 1200.
It means prolong timeout from 5 minutes to 20 minutes.
Is this correct way? Does exist other solution (for example manually set timeout per sessionbean / method) ?
Thank you very much,
Leonell