Ejb, Error in second method rolls back first method

I have poller scheduled like this

@Schedule(minute = "*/5", hour = "*", persistent = false)
public void pollTimer() {



private void startfirstPoller() {
// find all booking from database and update
private void startsecondPoller() {
// find all booking updated from database and update

The first method update some bookings, save them to database and second method use the updated information to process further and again update the database. The problem is changes doesn't reflect in the database until and unless second executes successfully. Moreover, exception in second method rollback the successful changes made by first method. Please let me know what is happening and how to make two method independent of each other.


I would assume that because you don't actually define the start and end of the transaction that it is managed by the container and spans the entire execution.

You can manage the transactions using annotations in java EE. Look up JTA which is the API for transactions.

The main problem with the code is that the @TransactionAttribute annotation has no effect at all. In your pollTimer() method you're doing a simple local method invocation, therefore the EJB container doesn't know that you want a new transaction for each of your poller methods.

If you inject an EJB with @EJB, the container injects only a proxy, therefore it can intercept the EJB method invocations and do the necessary work, like tx management. However, there is no interception in your case, because you're doing a local method invocation.

The following things happen in your case:

  • At time-out the pollTimer() method starts running in a new tx managed by the container
  • The first and the second poller method get invoked in the exact same tx.

Need Your Help

Make image fade out on mouseover in the div

css css3 html hover

I know my question may look weird at first, but let me explain...

Prefix notation to infix notation in Python

python math stack infix-notation prefix-notation

I am writing a small calculator (with prefix notation) and I'm curious how I'd convert prefix notation to infix notation. I currently have a function, but it's being weird, and I'm not sure how to ...