How to change EJB transaction timeout in Glassfish 4.1.1?

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 specifying the cmt-timeout-in-seconds parameter in the glassfish-ejb-jar.xml file, but I use the web module with its EJB classes and use Glassfish-web.xml accordingly.

Is there a way to change the timeout?

UPD:

The transaction timeout value in the transaction service settings is not affected.

@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");
}

This code works just fine. But if you 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 that, the service calls the doSomething () method again, and after 2 minutes I see errors again:

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

and the service no longer calls the doSomething () method.

+4
3

-, sun-ejb-jar.xml( 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>
+4

0 ( -), 120. Oracle 2.1.1, .

  • ( - 4848, <2 > )

  • : → server-config →

  • : -

GlassFish 4.1, 4.1.1.

+1

Source: https://habr.com/ru/post/1623067/


All Articles