2

I need to run a long running query via a stateless EJB.

statelessEjb.callLongRunningQuery();

I am using Weblogic and if the query is longer then 30 seconds it times out.

I configured the Set XA Transaction Timeout to true and XA Transaction Timeout to 900 seconds but still got timeout exception.

The only way worked was to set Timeout Seconds on JTA settings on the domain level.

Any idea why setting XA Transaction Timeout on datasource level was not ok ?

And most important : why i need a transaction using EJB when I just read data ...?

Thanks

Cris
  • 4,947
  • 6
  • 44
  • 73
  • This is basically the same question as: http://stackoverflow.com/questions/1307154/weblogic-transaction-timeout-how-to-set-in-admin-console-in-weblogic-as-8-1 Are you sure you have `Use XA Data Source Interface` checked? Why are you using XA for a read only method? There's no reason you have to use it – Display Name is missing Feb 05 '15 at 19:32
  • There is a bean managed transaction....well it is an XA driver and I use it to read data in this method but there are some scenarios where i need to insert into two dbs or to send a jms + write in db. – Cris Feb 05 '15 at 19:47
  • BTW any idea why for reading data with JPA via a session bean needs a transaction ? – Cris Feb 05 '15 at 19:51

1 Answers1

1

I have a partial answer for you:

And most important : why i need a transaction using EJB when I just read data ...?

You don't have to use a transaction, I had the same transaction timeout problem for a long running method. I used the @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) annotation to not use a transaction and thus avoiding the timeout.

In more details the bean code should look like this:

@Stateless
public class StatelessEjb {

  @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
  public void callLongRunningQuery() {
    ...// do long time stuff
  }
}
Shai Rippel
  • 428
  • 1
  • 4
  • 12