4 Replies Latest reply on Sep 19, 2004 11:54 PM by Colin Daly

    transaction-timeout not working

    Colin Daly Newbie

      Hi,

      in the change notes for 3.2.4 :
      http://www.jboss.org/index.html?module=bb&op=viewtopic&t=48895
      Adrian Brock has added per method transaction timeouts.
      I have been trying to get these working but it simply doesn't work for me. Here is a snippet from my jboss.xml which looks correct to me. I call these methods and I don't timeout for 5 mins - the default for the transaction manager.
      Is anyone successfully using per method transaction timeouts????


      <session>
       <ejb-name>TestTimeoutEJB</ejb-name>
       <jndi-name>TestTimeoutEJB</jndi-name>
      
       <method-attributes>
       <method>
       <method-name>tenSecondTimeout</method-name>
       <transaction-timeout>10</transaction-timeout>
       </method>
       <method>
       <method-name>twentySecondTimeout</method-name>
       <transaction-timeout>20</transaction-timeout>
       </method>
       </method-attributes>
      </session>
      


      Any help would be much appreciated.
      Cheers,
      Colin Daly


        • 1. Re: transaction-timeout not working
          Scott Stark Master

          The org.jboss.test.tm.test.TxTimeoutUnitTestCase in the testsuite runs fine on 3.2.4 so start by looking at it.

          <?xml version="1.0"?>
          <jboss>
          
           <enterprise-beans>
           <session>
           <ejb-name>TxTimeout</ejb-name>
           <jndi-name>jbosstest/tm/TxTimeout</jndi-name>
           <method-attributes>
           <method>
           <method-name>testOverriddenTimeoutExpires</method-name>
           <transaction-timeout>5</transaction-timeout>
           </method>
           <method>
           <method-name>testOverriddenTimeoutDoesNotExpire</method-name>
           <transaction-timeout>20</transaction-timeout>
           </method>
           </method-attributes>
           </session>
           </enterprise-beans>
          
          </jboss>
          



          • 2. Re: transaction-timeout not working
            Colin Daly Newbie


            Well I've had a good look Scott and I can't figure out what's
            happening here. The logging (see bottom) shows that the null is being returned as the content of the attibute "transaction-timeout" but this is not the case.

            I unjarred the jar in /tmp and ran the following code on it

             public static void main(String[] args)
             {
             try {
             XmlFileLoader xmlFileLoader = new XmlFileLoader(false);
             Document jbossDocument = xmlFileLoader.getDocumentFromURL(new URL("file:///tmp/jar/META-INF/jboss.xml"));
             ApplicationMetaData applicationMetaData = new ApplicationMetaData();
             Element entBeans = MetaData.getOptionalChild(jbossDocument.getDocumentElement(), "enterprise-beans");
             for (Iterator i = MetaData.getChildrenByTagName(entBeans, "session"); i.hasNext();) {
             Element bean = (Element) i.next();
             if (MetaData.getElementContent(bean, "ejb-name").indexOf("TestTimeoutEJB") > 0) {
             Element mas = MetaData.getOptionalChild(bean, "method-attributes");
             for (Iterator j = MetaData.getChildrenByTagName(mas, "method"); j.hasNext();) {
             MethodAttributes ma = new MethodAttributes();
             Element maNode = (Element) j.next();
             System.out.println(MetaData.getElementContent(MetaData.getUniqueChild(maNode, "method-name")));
             System.out.println(MetaData.getOptionalChildContent(maNode, "transaction-timeout"));
             }
            
             }
             }
             } catch (MalformedURLException e) {
             e.printStackTrace();
             } catch (DeploymentException e) {
             e.printStackTrace();
             }
             }
            



            2004-09-06 23:16:38,229 DEBUG [org.jboss.metadata.MetaData] Ignoring transaction-timeout 'null'
            java.lang.NumberFormatException: null
             at java.lang.Integer.parseInt(Integer.java:436)
             at java.lang.Integer.parseInt(Integer.java:518)
             at org.jboss.metadata.BeanMetaData.importJbossXml(BeanMetaData.java:789)
             at org.jboss.metadata.EntityMetaData.importJbossXml(EntityMetaData.java:341)
             at org.jboss.metadata.ApplicationMetaData.importJbossXml(ApplicationMetaData.java:729)
             at org.jboss.metadata.XmlFileLoader.load(XmlFileLoader.java:175)
             at org.jboss.ejb.EJBDeployer.create(EJBDeployer.java:462)
             at org.jboss.deployment.MainDeployer.create(MainDeployer.java:790)
             at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:644)
             at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:608)
             at sun.reflect.GeneratedMethodAccessor18.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:324)
             at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:185)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
             at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
             at $Proxy7.deploy(Unknown Source)
             at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:304)
             at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:478)
             at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:201)
             at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:212)
             at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:191)
            


            • 3. Re: transaction-timeout not working
              Colin Daly Newbie

              wooops - hit submit instead of preview


              anyway here is the output from my test code

              tenSecondTimeout
              10
              twentySecondTimeout
              20

              and for completeness here is my snippet from jboss.xml

               <session>
               <ejb-name>TestTimeoutEJB</ejb-name>
               <jndi-name>TestTimeoutEJB</jndi-name>
              
               <method-attributes>
               <method>
               <method-name>tenSecondTimeout</method-name>
               <transaction-timeout>10</transaction-timeout>
               </method>
               <method>
               <method-name>twentySecondTimeout</method-name>
               <transaction-timeout>20</transaction-timeout>
               </method>
               </method-attributes>
               </session>
              


              I can't figure out why null is being returned when the jar is being deployed - it should be the same code as what is in my test case....

              Colin.


              • 4. Re: transaction-timeout not working
                Colin Daly Newbie


                turns out those nulls were from a different method
                which had the read-only method attibute set and NOT the transaction-timeout.

                A debug message saying the null timeout is being ignored will be generated for every method with method attrbutes but no transaction-timeout in those attributes.

                Declarative timeout still doesn't seem to work for me in 3.2.5 so I'm doing it manually by getting the transaction service and setting the timeout attibute before my long method and then setting it back afterwards.