4

In Glassfish the EJB transaction timeout is set to 120 seconds by default, and I want to change this value.

I know that it can be changed by defining the "cmt-timeout-in-seconds" param in the glassfish-ejb-jar.xml, but I use the Web module with EJB classes in it, and use the glassfish-web.xml respectively.

Is there any way to change the timeout?

UPD:

The Transaction Timeout value in the Transaction Service settings has no effect.

@Schedule(minute = "*/5", hour = "*", persistent = false)
public void doSomething() {
    log.info("Started");
    try {
        Thread.sleep(1000 * 119);
    } catch (InterruptedException ex) {
        log.info("Interrupted", ex);
    }
    log.info("Finished");
}

The code above works fine. But if to change the sleep time to 121 seconds

Thread.sleep(1000 * 121);

in the GF Server log I see an error:

Warning:   EJB5123:Rolling back timed out transaction

After this, the service invokes the doSomething() method once more, and in 2 minutes I see errors again:

Warning:   EJB5123: Rolling back timed out transaction
Info:   EJB5119:Expunging timer [...] after [2] failed deliveries

and the service doesn't invoke the doSomething() method anymore.

LazyWorker
  • 129
  • 2
  • 11

3 Answers3

4

Even if it's a web module, add the sun-ejb-jar.xml (or glassfish-ejb-jar.xml):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 EJB 3.0//EN" "http://www.sun.com/software/appserver/dtds/sun-ejb-jar_3_0-0.dtd">
<sun-ejb-jar>
    <enterprise-beans>
         <ejb>
            <ejb-name>YourEjbName</ejb-name>
            <cmt-timeout-in-seconds>1200</cmt-timeout-in-seconds>
         </ejb>
    </enterprise-beans>
</sun-ejb-jar>
bebbo
  • 2,830
  • 1
  • 32
  • 37
1

The default value for transaction timeout is 0 (no timeouts), not 120. There is Oracle tutorial for version 2.1.1 which looks like not outdated.

Tested on GlassFish 4.1, shouldn't be much of a difference in 4.1.1.

Geinmachi
  • 1,251
  • 1
  • 8
  • 20
  • I have exactly the same problem as the original poster. Used to work fine on Glassfish 4.1 -- only started receiving the error after upgrading to 4.1.1. No timeout value is specified within domain.xml. I'll try adding an explicit timeout of 0, and report back in a few days. – Franzl Jan 19 '16 at 08:59
  • To confirm, the explicit timeout of 0 has no material effect. My scheduled methods continue to timeout. – Franzl Jan 20 '16 at 11:11
  • 1
    I have experienced the same bug and now there seems to be an issue created for it: https://java.net/jira/browse/GLASSFISH-21495 – napu Feb 12 '16 at 15:41
0

This is a reported bug.

http://java.net/jira/browse/GLASSFISH-21495

With me is when I have a method importing a large amount of data and calling flush.