2012-10-22 43 views
8

我目前正試圖升級從JBoss的5.1我的web應用到JBoss 7.1.1.Final的Jboss 7.1 EJB 2.1的定製事務超時配置

在我的jboss.xml我已經配置了一些自定義EJB超時像下面:

 <session> 
     <ejb-name>MSServiceEJB</ejb-name> 
     <jndi-name>ejb/MSServiceEJB</jndi-name> 
     <local-jndi-name>ejb/LocalMSServiceEJB</local-jndi-name> 
     <method-attributes> 
      <method> 
       <method-name>*</method-name> 
       <transaction-timeout>3600</transaction-timeout> 
      </method> 
     </method-attributes> 
    </session> 

jboss 7忽略jboss.xml,我可以在哪裏指定我的ejb 2.1事務超時?

回答

6

Source

更換的jboss.xml部署描述符文件

jboss-ejb3.xml部署描述符將jboss.xml部署描述符替換爲 覆蓋並添加到Java Enterprise Edition(EE)定義的ejb3-jar.xml部署描述符提供的功能。新文件 與jboss.xml不兼容,現在在 部署中忽略jboss.xml。

您需要創建一個jboss-ejb3.xml並將其中的配置。

這將是這個樣子:

<assembly-descriptor> 
    <container-transaction> 
     <method> 
      <ejb-name>EJBName</ejb-name> 
      <method-name>methodName</method-name> 
      <method-intf>Local</method-intf> 
     </method> 
     <tx:trans-timeout> 
      <tx:timeout>500</tx:timeout> 
      <tx:unit>Seconds</tx:unit> 
     </tx:trans-timeout> 
    </container-transaction> 
</assembly-descriptor> 

您使用EJB2.x,所以這將是更好的和明智的配置它在ejb-jar.xml

應該在META-INF of the EJB jar創建。

+0

@Yishai:謝謝你的更新sir :-) –

+1

如果有人問自己爲xxmns設置了tx:它是「urn:trans-timeout」(描述過[這裏](https://docs.jboss.org/author/display/AS7/EJB+3+Reference+Guide)) –

2

您可以使用@TransactionTimeOut批註在Bean方法上指定。

@TransactionTimeout(value = 10, unit = TimeUnit.SECONDS) 

有關如何設置的詳細說明,請參閱here

馬迪

+3

這是爲EJB 3而不是EJB 2. – Vadzim