Posts

Showing posts with the label Spring Batch

Could Not Open JPA EntityManager For Transaction; Nested Exception Is Java.lang.IllegalStateException

Answer : The error comes from JpaTransactionManager line 403: TransactionSynchronizationManager.bindResource(getDataSource(), conHolder); The error means that the transaction manager is trying to bind the datasource (not the entity manager) to the thread, but the datasource is already there and this is unexpected. Note that the transaction manager had not started yet to bind the Entity Manager to the thread, that would happen next at JpaTransactionManager line 416: There are two possible explanations: Somebody (another transaction manager?) is adding the datasource to the thread before the transaction manager and this is unexpected. Or noone is adding the datasource to the transaction manager, is just that at the end of the task execution noone cleans the thread before returning it to the pool, maybe due an error or an unhandled exception. One question, does this also happen for only one execution thread, or only when there are several? To find out what the problem is, these are so...