Knowledge (XXG)

Jakarta Transactions

Source 📝

973: 917: 949: 228:
Transaction context propagation between application programs is provided by the underlying transaction manager implementations on the client and server machines. The transaction context format used for propagation is protocol dependent and must be negotiated between the client and server hosts. For
197:
The Jakarta Transactions API consists of three elements: a high-level application transaction demarcation interface, a high-level transaction manager interface intended for an application server, and a standard Java mapping of the X/Open XA protocol intended for a transactional resource manager.
626:
annotation. Thus, an EJB application does not interface with the Transaction Manager directly for transaction demarcation; instead, the EJB bean relies on the EJB server to provide support for all of its transaction work as defined in the Jakarta Enterprise Beans Specification. (The underlying
224:
Support for nested transactions is not required. The UserTransaction.begin method throws the NotSupportedException when the calling thread is already associated with a transaction and the transaction manager implementation does not support nested transactions.
98:
API to work with relational databases. In addition, the resource manager allows a TP monitor to coordinate a distributed transaction between its own and other resource managers. Finally, there is the application which communicates with the TP monitor to begin,
94:(TP monitor) coordinates the transactions across multiple resources such as databases and message queues. Each resource has its own resource manager. The resource manager typically has its own API for manipulating the resource, for example the 247:
annotation provides the application the ability to control transaction boundaries declaratively. This annotation can be applied to any class that the Jakarta EE specification defines as a managed bean (which includes CDI managed beans).
573:
is called, the number printed will be 0 and not 1. This is because each method had its own transaction and therefore its own instance of TxScopedBean. The number 1 that was set during the call to
233:
specification, it will use the transaction context propagation format as specified in the CORBA OTS 1.1 specification. Transaction propagation is transparent to application programs.
221:
method starts a global transaction and associates the transaction with the calling thread. The transaction-to-thread association is managed transparently by the Transaction Manager.
627:
interaction between the EJB Server and the TM is transparent to the application; the burden of implementing transaction management is on the EJB container and server provider.)
212:
interface provides the application the ability to control transaction boundaries programmatically. This interface may be used by Java client programs or EJB beans.
138:
The JTA is modelled on the X/Open XA architecture, but it defines two different APIs for demarcating transaction boundaries. It distinguishes between an
330:
annotation provides the application the ability to declare that the scope during which a bean lives is tied to the time a given transaction is active.
1285: 1020: 152:, that is used by the application server itself to begin, commit and roll back the transactions. It provides a different interface, the 167:
interface in order to be managed by the TP monitor. As stated previously, each resource will have its own specific API, for instance:
1280: 46: 1275: 312:
Transactional behavior can be configured via an attribute on the annotation. The available options closely mirror those of the
217: 107:
the transactions. The application also communicates with the individual resources using their own API to modify the resource.
185: 91: 1169: 1164: 181: 148: 131: 326: 1154: 1061: 208: 154: 124: 1239: 1056: 922: 58: 600: 243: 163: 1249: 1244: 1176: 104: 95: 978: 1159: 1106: 1013: 930: 230: 143: 100: 50: 1213: 62: 983: 1096: 1051: 175: 1192: 1136: 1111: 1088: 1006: 1290: 1223: 1197: 1131: 139: 1116: 158:, that is used by general client code such as a servlet or an EJB to manage the transactions. 1218: 1101: 1046: 1038: 893:
is thus not necessary in EJB programming, but might be needed for very specialized code.
972: 950:
JSR 220: Enterprise JavaBeans,Version 3.0, EJB 3.0 Expert Group, Sun Microsystems, 2006
1269: 1066: 17: 1126: 116: 569:
is first called on a managed instance of ExampleBean and then subsequently method
966: 1146: 916: 1029: 912: 43: 1078: 998: 161:
The JTA architecture requires that each resource manager must implement the
85: 72: 54: 879:
annotation is omitted, a JTA transaction is automatically started whenever
1071: 304:// After the method returns transaction is committed or rolled back 993: 604:
annotation (this is called bean-managed transactions or BMT). The
1254: 229:
example, if the transaction manager is an implementation of the
1002: 146:
server and an application component. It provides an interface,
589: 313: 883:
is called and is automatically committed or rolled back when
905:(if a JTA implementation is installed in the environment). 610:
interface is exposed to EJB components through either the
598:
interface for use by EJB beans with the BEAN value in the
27:
Jakarta EE specification for transactional resource access
61:
environment. JTA was a specification developed under the
90:
In the X/Open XA architecture, a transaction manager or
988: 636:
via bean-managed transactions in an EJB session bean:
75:
API allowing resources to participate in transactions.
622:
method, or directly via injection using the general
1232: 1206: 1185: 1145: 1087: 1037: 888: 746: 740: 631: 617: 611: 605: 593: 334: 252: 111:JTA implementation of the X/Open XA architecture 630:The code sample below illustrates the usage of 333:The code sample below illustrates the usage of 251:The code sample below illustrates the usage of 901:The UserTransaction should be available under 577:will therefore not be seen during the call to 1014: 875:Note though that in the example above if the 8: 1021: 1007: 999: 971: 942: 115:The JTA API consists of classes in two 339:in a request scoped CDI managed bean: 257:in a request scoped CDI managed bean: 585:UserTransaction support in EJB server 69:demarcation of transaction boundaries 7: 994:Bitronix transaction manager website 989:Narayana transaction manager website 984:Atomikos transaction manager website 592:servers are required to support the 149:javax.transaction.TransactionManager 327:javax.transaction.TransactionScoped 25: 209:javax.transaction.UserTransaction 193:Application Programming Interface 155:javax.transaction.UserTransaction 915: 897:UserTransaction support in JNDI 601:javax.ejb.TransactionManagement 295:// A transaction is active here 244:javax.transaction.Transactional 164:javax.transaction.xa.XAResource 92:transaction processing monitor 65:as JSR 907. JTA provides for: 1: 320:@TransactionScoped annotation 182:Enterprise Information System 171:relational databases use JDBC 877:@TransactionManagement(BEAN) 1286:Java specification requests 923:Computer programming portal 887:is exited. Making use of a 53:to be done across multiple 1307: 83: 903:java:comp/UserTransaction 745:can be obtained from the 237:@Transactional annotation 202:UserTransaction interface 1281:Java enterprise platform 931:Java transaction service 753: 638: 341: 259: 51:distributed transactions 218:UserTransaction.begin() 174:messaging services use 1276:Transaction processing 834:// start a transaction 759:@TransactionManagement 698:// start a transaction 644:@TransactionManagement 80:X/Open XA architecture 63:Java Community Process 1255:Streaming API for XML 1170:Web Services Metadata 1165:SOAP with Attachments 186:Java EE Connector API 1097:Dependency injection 616:interface using the 132:javax.transaction.xa 40:Java Transaction API 32:Jakarta Transactions 18:Java Transaction API 1057:Expression Language 739:Alternatively, the 828:getUserTransaction 619:getUserTransaction 344:@TransactionScoped 336:@TransactionScoped 140:application server 1263: 1262: 184:) resources use 180:generalized EIS ( 125:javax.transaction 16:(Redirected from 1298: 1107:Enterprise Beans 1023: 1016: 1009: 1000: 975: 970: 969: 967:Official website 952: 947: 925: 920: 919: 904: 892: 891: 886: 882: 878: 871: 868: 865: 862: 859: 856: 853: 850: 847: 844: 841: 838: 835: 832: 829: 826: 823: 820: 817: 814: 811: 808: 805: 802: 799: 796: 793: 790: 787: 784: 781: 778: 775: 772: 769: 766: 763: 760: 757: 750: 749: 744: 743: 735: 732: 729: 726: 723: 720: 717: 714: 711: 708: 705: 702: 699: 696: 693: 690: 687: 684: 681: 678: 675: 672: 669: 666: 663: 660: 657: 654: 651: 648: 645: 642: 635: 634: 625: 621: 620: 615: 614: 609: 608: 603: 597: 596: 561: 558: 555: 552: 549: 546: 543: 540: 537: 534: 531: 528: 525: 522: 519: 516: 513: 510: 507: 504: 501: 498: 495: 492: 489: 486: 483: 480: 477: 474: 471: 468: 465: 462: 459: 456: 453: 450: 447: 444: 441: 438: 435: 432: 429: 426: 423: 420: 417: 414: 411: 408: 405: 402: 399: 396: 393: 390: 387: 384: 381: 378: 375: 372: 369: 366: 363: 360: 357: 354: 351: 348: 345: 338: 337: 329: 308: 305: 302: 299: 296: 293: 290: 287: 284: 281: 278: 275: 272: 269: 266: 263: 256: 255: 246: 220: 211: 166: 157: 151: 134: 127: 21: 1306: 1305: 1301: 1300: 1299: 1297: 1296: 1295: 1266: 1265: 1264: 1259: 1228: 1202: 1181: 1141: 1102:Bean Validation 1083: 1033: 1027: 965: 964: 961: 956: 955: 948: 944: 939: 921: 914: 911: 902: 899: 890:UserTransaction 889: 884: 880: 876: 873: 872: 869: 866: 863: 860: 857: 854: 851: 848: 845: 842: 839: 836: 833: 830: 827: 824: 821: 818: 815: 813:UserTransaction 812: 809: 806: 803: 800: 797: 794: 791: 788: 785: 782: 779: 776: 773: 770: 767: 764: 761: 758: 755: 747: 742:UserTransaction 741: 737: 736: 733: 730: 727: 724: 721: 718: 715: 712: 709: 706: 703: 700: 697: 694: 691: 688: 685: 682: 679: 676: 674:UserTransaction 673: 670: 667: 664: 661: 658: 655: 652: 649: 646: 643: 640: 633:UserTransaction 632: 623: 618: 612: 607:UserTransaction 606: 599: 595:UserTransaction 594: 587: 563: 562: 559: 556: 553: 550: 547: 544: 541: 538: 535: 532: 529: 526: 523: 520: 517: 514: 511: 508: 505: 502: 499: 496: 493: 490: 487: 484: 481: 478: 475: 472: 469: 466: 463: 460: 457: 454: 451: 448: 445: 442: 439: 436: 433: 430: 427: 424: 421: 418: 415: 412: 409: 406: 403: 400: 397: 394: 391: 388: 385: 382: 379: 376: 373: 370: 367: 364: 361: 358: 355: 352: 349: 346: 343: 335: 325: 322: 316:specification. 310: 309: 306: 303: 300: 297: 294: 291: 288: 285: 282: 279: 276: 273: 270: 267: 264: 261: 253: 242: 239: 216: 207: 204: 195: 162: 153: 147: 130: 123: 113: 88: 82: 57:resources in a 28: 23: 22: 15: 12: 11: 5: 1304: 1302: 1294: 1293: 1288: 1283: 1278: 1268: 1267: 1261: 1260: 1258: 1257: 1252: 1247: 1242: 1236: 1234: 1230: 1229: 1227: 1226: 1221: 1216: 1210: 1208: 1204: 1203: 1201: 1200: 1195: 1189: 1187: 1183: 1182: 1180: 1179: 1174: 1173: 1172: 1167: 1157: 1151: 1149: 1143: 1142: 1140: 1139: 1134: 1129: 1124: 1119: 1114: 1109: 1104: 1099: 1093: 1091: 1089:Enterprise app 1085: 1084: 1082: 1081: 1076: 1075: 1074: 1064: 1059: 1054: 1049: 1043: 1041: 1035: 1034: 1032:specifications 1028: 1026: 1025: 1018: 1011: 1003: 997: 996: 991: 986: 981: 976: 960: 959:External links 957: 954: 953: 941: 940: 938: 935: 934: 933: 927: 926: 910: 907: 898: 895: 789:SessionContext 754: 748:SessionContext 639: 586: 583: 509:@Transactional 470:@Transactional 440:@RequestScoped 342: 321: 318: 277:@Transactional 262:@RequestScoped 260: 254:@Transactional 238: 235: 203: 200: 194: 191: 190: 189: 178: 172: 136: 135: 128: 112: 109: 84:Main article: 81: 78: 77: 76: 70: 42:), one of the 26: 24: 14: 13: 10: 9: 6: 4: 3: 2: 1303: 1292: 1289: 1287: 1284: 1282: 1279: 1277: 1274: 1273: 1271: 1256: 1253: 1251: 1248: 1246: 1243: 1241: 1238: 1237: 1235: 1231: 1225: 1222: 1220: 1217: 1215: 1212: 1211: 1209: 1205: 1199: 1196: 1194: 1191: 1190: 1188: 1184: 1178: 1175: 1171: 1168: 1166: 1163: 1162: 1161: 1158: 1156: 1153: 1152: 1150: 1148: 1144: 1138: 1135: 1133: 1130: 1128: 1125: 1123: 1120: 1118: 1115: 1113: 1110: 1108: 1105: 1103: 1100: 1098: 1095: 1094: 1092: 1090: 1086: 1080: 1077: 1073: 1070: 1069: 1068: 1065: 1063: 1060: 1058: 1055: 1053: 1050: 1048: 1045: 1044: 1042: 1040: 1036: 1031: 1024: 1019: 1017: 1012: 1010: 1005: 1004: 1001: 995: 992: 990: 987: 985: 982: 980: 977: 974: 968: 963: 962: 958: 951: 946: 943: 936: 932: 929: 928: 924: 918: 913: 908: 906: 896: 894: 752: 637: 628: 602: 591: 584: 582: 580: 576: 572: 568: 340: 331: 328: 319: 317: 315: 258: 249: 245: 236: 234: 232: 226: 222: 219: 213: 210: 201: 199: 192: 187: 183: 179: 177: 173: 170: 169: 168: 165: 159: 156: 150: 145: 141: 133: 129: 126: 122: 121: 120: 118: 117:Java packages 110: 108: 106: 102: 97: 93: 87: 79: 74: 71: 68: 67: 66: 64: 60: 56: 52: 48: 45: 41: 37: 33: 19: 1147:Web services 1121: 945: 900: 874: 852:// Commit it 738: 716:// Commit it 629: 588: 578: 574: 570: 566: 564: 545:tXscopedBean 488:txScopedBean 464:txScopedBean 461:TxScopedBean 353:TxScopedBean 332: 323: 311: 250: 240: 227: 223: 214: 205: 196: 160: 137: 114: 89: 39: 35: 31: 29: 1137:Annotations 777:ExampleBean 662:ExampleBean 449:ExampleBean 271:ExampleBean 142:such as an 38:; formerly 1270:Categories 1224:Management 1030:Jakarta EE 937:References 849:// Do work 756:@Stateless 713:// Do work 641:@Stateless 613:EJBContext 565:If method 298:// Do work 49:, enables 44:Jakarta EE 1291:Java APIs 1079:WebSocket 783:@Resource 668:@Resource 624:@Resource 551:getNumber 494:setNumber 401:setNumber 377:getNumber 105:roll back 86:X/Open XA 73:X/Open XA 55:X/Open XA 1072:Facelets 909:See also 1233:Related 1219:JAX-RPC 1207:Removed 1047:Servlet 1039:Web app 979:JSR 907 786:private 671:private 458:private 455:@Inject 1160:JAX-WS 1155:JAX-RS 861:commit 798:public 771:public 725:commit 683:public 656:public 527:System 512:public 473:public 443:public 431:number 425:number 410:number 395:public 389:number 386:return 371:public 365:number 359:public 347:public 280:public 265:public 101:commit 1186:Other 1067:Faces 1052:Pages 885:foo() 881:foo() 843:begin 774:class 707:begin 659:class 579:bar() 575:foo() 571:bar() 567:foo() 539:print 446:class 350:class 268:class 1245:JDBC 1240:JAXP 1214:JAXR 1193:JAXB 1177:JAXM 1127:Mail 1062:JSTL 801:void 765:BEAN 686:void 650:BEAN 554:()); 515:void 476:void 419:this 398:void 324:The 283:void 241:The 215:The 206:The 96:JDBC 59:Java 47:APIs 30:The 1250:JMX 1198:JAF 1132:JCA 1122:JTA 1117:JMS 1112:JPA 864:(); 855:utx 846:(); 837:utx 831:(); 822:ctx 816:utx 804:foo 792:ctx 728:(); 719:utx 710:(); 701:utx 689:foo 677:utx 590:EJB 533:out 518:bar 479:foo 407:int 374:int 362:int 314:EJB 286:foo 231:JTS 176:JMS 144:EJB 103:or 36:JTA 1272:: 807:() 751:: 692:() 581:. 521:() 503:); 482:() 434:;} 392:;} 380:() 289:() 119:: 1022:e 1015:t 1008:v 870:} 867:} 858:. 840:. 825:. 819:= 810:{ 795:; 780:{ 768:) 762:( 734:} 731:} 722:. 704:. 695:{ 680:; 665:{ 653:) 647:( 560:} 557:} 548:. 542:( 536:. 530:. 524:{ 506:} 500:1 497:( 491:. 485:{ 467:; 452:{ 437:} 428:= 422:. 416:{ 413:) 404:( 383:{ 368:; 356:{ 307:} 301:} 292:{ 274:{ 188:. 34:( 20:)

Index

Java Transaction API
Jakarta EE
APIs
distributed transactions
X/Open XA
Java
Java Community Process
X/Open XA
X/Open XA
transaction processing monitor
JDBC
commit
roll back
Java packages
javax.transaction
javax.transaction.xa
application server
EJB
javax.transaction.TransactionManager
javax.transaction.UserTransaction
javax.transaction.xa.XAResource
JMS
Enterprise Information System
Java EE Connector API
javax.transaction.UserTransaction
UserTransaction.begin()
JTS
javax.transaction.Transactional
EJB
javax.transaction.TransactionScoped

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.