Transaction settings in ejbs.

Hi all,
I have three questions:
1) I have several EJBs related to different business entities being called within one single transaction by the client;
I would like to know if it is better to have bean lvel transaction setting or method level transaction setting.
2) If TX_REQUIRED is put at the method level that involve create/save/delete SQL statements.Can TX_NOT_SUPPORTED transaction attribute be set to the methods that involve DML statement(Select statements).
3) Also is there any restriction that the calling method within a single large transaction must hvae more restrictive transaction attribute
(with TX_REQUIRED) than the method that is being called
(with TX_NOT_SUPPORTS/TX_SUPPORTS) or vice versa.
thanks in advance.

1) EJBs server handle concurrency automatically, a bean's methods do not have to be made a thread-safe.The EJB specification prohibits use of the synchronized keyword.
The EJB container has to maintain complete control over the concurrency, transaction and persistence.

Similar Messages

  • Assignment of transaction attributes in ejb-jar.xml

    Hi all,
    I'm going through the employee example from the book "Java programming in SAP web application server". I have followed the instrucstions to the letter and have triple checked that i did not miss anything.
    During the part "Defining Transaction Control", when i go to the "Assembly" tab, choose "Container-transaction" and click add; i get the following error message.
    You have to create and reference EJBs first. Afterwards you can choose them here.
    Newly created EJBs are referenced automatically in the ejb-jar.xml, in special cases you might have to reference them manually.
    Below is a copy of the ejb-jar. Both beans are referenced in the file so i don't really understand the error message!
    Thanks for your help.
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
    <ejb-jar>
         <description>EJB JAR description</description>
         <display-name>EJB JAR</display-name>
         <enterprise-beans>
              <session>
                   <ejb-name>EmployeeServicesBean</ejb-name>
                   <home>com.sap.demo.EmployeeServicesHome</home>
                   <remote>com.sap.demo.EmployeeServices</remote>
                   <local-home>com.sap.demo.EmployeeServicesLocalHome</local-home>
                   <local>com.sap.demo.EmployeeServicesLocal</local>
                   <ejb-class>com.sap.demo.EmployeeServicesBean</ejb-class>
                   <session-type>Stateless</session-type>
                   <transaction-type>Container</transaction-type>
                   <ejb-local-ref>
                        <ejb-ref-name>ejb/Employee</ejb-ref-name>
                        <ejb-ref-type>Entity</ejb-ref-type>
                        <local-home>com.sap.demo.EmployeeLocalHome</local-home>
                        <local>com.sap.demo.EmployeeLocal</local>
                        <ejb-link>EmployeeEjb.jar#EmployeeBean</ejb-link>
                   </ejb-local-ref>
              </session>
              <entity>
                   <ejb-name>EmployeeBean</ejb-name>
                   <home>com.sap.demo.EmployeeHome</home>
                   <remote>com.sap.demo.Employee</remote>
                   <local-home>com.sap.demo.EmployeeLocalHome</local-home>
                   <local>com.sap.demo.EmployeeLocal</local>
                   <ejb-class>com.sap.demo.EmployeeBean</ejb-class>
                   <persistence-type>Container</persistence-type>
                   <prim-key-class>java.lang.Long</prim-key-class>
                   <reentrant>False</reentrant>
                   <cmp-version>2.x</cmp-version>
                   <abstract-schema-name>EmployeeBean</abstract-schema-name>
                   <cmp-field>
                        <field-name>lastname</field-name>
                   </cmp-field>
                   <cmp-field>
                        <field-name>firstname</field-name>
                   </cmp-field>
                   <cmp-field>
                        <field-name>id</field-name>
                   </cmp-field>
                   <cmp-field>
                        <field-name>department</field-name>
                   </cmp-field>
                   <primkey-field>id</primkey-field>
                   <query>
                        <description>Query for getting all employee objects.</description>
                        <query-method>
                             <method-name>findAllEmployees</method-name>
                             <method-params/>
                        </query-method>
                        <ejb-ql>Select object (p) from EmployeeBean p</ejb-ql>
                   </query>
              </entity>
         </enterprise-beans>
         <assembly-descriptor/>
    </ejb-jar>

    I was able to add the transaction attributes manually to the ejb-jar.xml file. below is what the file looks like now for those interested.
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
    <ejb-jar>
         <description>EJB JAR description</description>
         <display-name>EJB JAR</display-name>
         <enterprise-beans>
              <session>
                   <ejb-name>EmployeeServicesBean</ejb-name>
                   <home>com.sap.demo.EmployeeServicesHome</home>
                   <remote>com.sap.demo.EmployeeServices</remote>
                   <local-home>com.sap.demo.EmployeeServicesLocalHome</local-home>
                   <local>com.sap.demo.EmployeeServicesLocal</local>
                   <ejb-class>com.sap.demo.EmployeeServicesBean</ejb-class>
                   <session-type>Stateless</session-type>
                   <transaction-type>Container</transaction-type>
                   <ejb-local-ref>
                        <ejb-ref-name>ejb/Employee</ejb-ref-name>
                        <ejb-ref-type>Entity</ejb-ref-type>
                        <local-home>com.sap.demo.EmployeeLocalHome</local-home>
                        <local>com.sap.demo.EmployeeLocal</local>
                        <ejb-link>EmployeeEjb.jar#EmployeeBean</ejb-link>
                   </ejb-local-ref>
              </session>
              <entity>
                   <ejb-name>EmployeeBean</ejb-name>
                   <home>com.sap.demo.EmployeeHome</home>
                   <remote>com.sap.demo.Employee</remote>
                   <local-home>com.sap.demo.EmployeeLocalHome</local-home>
                   <local>com.sap.demo.EmployeeLocal</local>
                   <ejb-class>com.sap.demo.EmployeeBean</ejb-class>
                   <persistence-type>Container</persistence-type>
                   <prim-key-class>java.lang.Long</prim-key-class>
                   <reentrant>False</reentrant>
                   <cmp-version>2.x</cmp-version>
                   <abstract-schema-name>EmployeeBean</abstract-schema-name>
                   <cmp-field>
                        <description>
                        </description>
                        <field-name>lastname</field-name>
                   </cmp-field>
                   <cmp-field>
                        <description>
                        </description>
                        <field-name>firstname</field-name>
                   </cmp-field>
                   <cmp-field>
                        <description>
                        </description>
                        <field-name>id</field-name>
                   </cmp-field>
                   <cmp-field>
                        <description>
                        </description>
                        <field-name>department</field-name>
                   </cmp-field>
                   <primkey-field>id</primkey-field>
                   <query>
                        <description>Query to get all employee objects.</description>
                        <query-method>
                             <method-name>findAllEmployees</method-name>
                             <method-params/>
                        </query-method>
                        <ejb-ql>Select object (p) from EmployeeBean p</ejb-ql>
                   </query>
              </entity>
         </enterprise-beans>
         <assembly-descriptor>
              <container-transaction>
                   <description>container-transaction</description>
                   <method>
                        <ejb-name>EmployeeBean</ejb-name>
                        <method-name>*</method-name>
                   </method>
                   <method>
                        <ejb-name>EmployeeServicesBean</ejb-name>
                        <method-name>*</method-name>
                   </method>
                   <trans-attribute>Required</trans-attribute>
              </container-transaction>
         </assembly-descriptor>
    </ejb-jar>
    Thanks

  • Transaction problem in ejb

    Hi
    I have a problem related to CMP entity beans.
    I am using Oracle 9i and weblogic 6.1
    Here is the description of the problem.
    The transaction attribute of all the beans is set to 'Required'.
    I have a PersonBean (CMP) in Person.jar mapping to Person table along with other
    beans.
    I have a MemberBean(CMP) in Member.jar file mapping to Member table along with
    many other beans.
    There is a one to many relation ship between person and member tables in Oracle
    9i database :
    Id in the person table is the P_Key and Person_Id in Member table is the related
    foreign key.
    No relationship was made between Person and Member beans as there were in two
    different jar files with different deployment descriptors.
    I have a stateless session bean PersonService bean.
    There is a method in PersonService bean called createPerson(String name);
    This method creates Person in the database using Person p = PersonHome.create(),
    long personId = p.getId()..returns the primary key of the person.
    PersonService calls createMember(long personId) now.
    which will try to create a Member record in the database using the personId.
    Now the Member bean fails to create and the transaction is rolled back with a
    foreign_key violation exception.
    because it cannot locate the Person EJB Primary key entry in the underlying table.
    But the EJB cache is still inserted properly with Person EJB (findByPrimaryKey
    works).
    I feel that Member bean is not able to participate in the same transaction of
    the Person bean inspite of keeping the transaction attribute to 'Required'.
    When I keep the transaction of Person bean to 'RequiresNew', then the transation
    of createPerson is getting committed and Member is starting a New transaction
    and it gets created.
    But I donot want like this.
    I want all the beans to be participating in the same transaction.
    According to Oracle / Weblogic documentation the default database isolation mode
    Read_Committed should allow participants in transaction to see uncommitted data
    while participants outside the transaction see only committed data. I have tried
    other dataabase isolation modes (such as Read_Uncommitted, "Serializable") these
    appear to either create other problems or not have an affect.
    Any solution to this problem is highly appreciated.
    Thanks
    Lavanya

    Previously our code was running on Weblogic where
    methodA() -> Transaction Attribute -> Supports
    methodB() -> Transaction Attribute -> Required
    But in JBOSS in order to run the same thing we have to do
    methodA() -> Transaction Attribute -> Required
    methodB() -> Transaction Attribute -> Required
    Any Pointers??

  • Can I use JTA transactions in a EJB that calls a webservice

    Hi,
    I created a EJB Client that calls two web services with JTA transactions. I would like to undo the first web services when the second one fails. Is this possible at all? If yes, is JTA the right way to do this?
    Thank you
    Julia

    You may be able to but it all depends on the RAM and the system. Some work, Some Don't.
    But if you haven't already bought the RAM just buy what is right for the system.
    Even if the faster RAM works it will not run at the faster speed. It would be Clocked down to the speed of the system it is installed in.

  • "Do not finalize my PayPal transactions" settings

    Hi,
    I am having an issue with the "Do not finalize my PayPal transactions." box for Paypal transactions.
    Even though I have this box checked, transactions are still completeing within Paypal, when they should not be.
    The set-up from the Business Catalyst end seems very simple. Account email address, PDT token and box checked. That's all there is to it.
    Therefore, it seems there must be a setting within Paypal to stop these transactions from completeing. Does any one know what needs to be done from within the account so this "Do not finalize my PayPal transactions." setting actually takes effect?
    I've tried speaking to Paypal but they said "To being using authorisation and capture for Website Payment Standard, you would need to add the code "paymentaction=authorization" to your button"
    However, there is no button, it's all within the BC system. Therefore, how do you actually set up "Do not finalize my PayPal transactions."?
    Richard

    Hi Richard,
    I've checked your site and I recommend the following. 
    Create a 1 cent test product
    "Retick" the do not finalize option in BC (I'm seeing it unticked at the moment). 
    Conduct a 1cent test purchase under the live gateway (not the test/sandbox version)
    If you are still seeing the transaction processing on Paypal's end please reach out to our direct support once again.  They might need your credentials to verify your PayPal settings because this would typically be setting that needs to be adjust on PayPal's end. 
    Kind regards,
    -Sidney

  • Transaction handling between EJBs

    hi,
    I am having a delegate kind of Stateless Session Bean(SSB which calls three other SSBs and perform database operations. My delegate bean does not have any database activities associated with it.
    I am using container managed transaction and setting transaction attribute for the business function calling the 3 SSBs as RequiresNew. I have set the transaction attribute for the other 3 beans as Required. But when there is a update error, the transaction is not rolling back. Have someone come across similar problem?
    Thanks in advance.
    Regards,
    Karthik

    An user exception (in the EJB spec. called application exception) must not be extend RunTimeException.
    Hi crackers, here are some sentences from the EJB specification:
    Code that you develop should not throw EJBException - that's "reserved" for the container vendor to signal a container failure.EJB Spec. 2.0 (page373):
    If the bean method performs an operation that results in a checked exception[32] that the bean
    method cannot recover, the bean method should throw the javax.ejb.EJBException
    that wraps the original exception.
    Not entirely accurate. If a user-defined Exception extends the Exception class, yes, you must explicitly rollback the transaction. However, if the user-defined Exception extends RuntimeException, the container will roll back the exception for you.EJB Spec. 2.0 (page372):
    An application exception class must be a subclass (direct or indirect) of java.lang.Exception.
    An application exception class must not be defined as a subclass of the java.lang.RuntimeException
    or of the java.rmi.RemoteException.

  • Transaction handling in EJBs

    i dont know ejb�s handle transaction.
    any sugesstions??????
    sorry my english, ciao

    http://www.google.com/search?hl=en&q=EJB+transaction+handling
    Especially look at this one:
    http://www.kevinboone.com/ejb-transactions.html

  • XA transaction settings in BPEL

    I want to implement the XA transaction in my BPEL process
    I have made the follwing settings
    define a XA datasource define the Connection Factory.
    Defining Datasource and Connection Pool
    set transaction as participate in bpel.xml (for global transaction)
    what settings do I need to do at partner link level.
    It is still failing for XA Transaction level.
    It will be great if someone can help me out on this issue.

    Hi,
    the BPEL forum is at BPEL
    Frank

  • How to commit/rollback a transaction encompasing multiple EJBs

    I have 2 Stateless Session Beans 'RulesManager' and 'BankManager'. Each EJB method in them gets a connection, perform the task, close the connection and return the results.
    Now in RulesManager I have an EJB method processRules(). And in BankManager I have an EJB method updateTransactions().
    I have a requirement that means I first have to call BankManager's updateTransactions() method; if successful then call RulesManager's processRules() method. IF its successfull as well then commit else rollback.
    I dont know how to do this. Can anybody help me in this regard?
    Thanks

    Thanks kdgregory. This is how the things work out in our application.
    I have a class BankDelegate which has each public method in BankManager SSB without the throws clause. Inside each method I get remote interface of BankManager SSB and then calls the corresponding EJB method.
    Similarly I have a RulesDelegate class which has each public method in RulesManager SSB without the throws clause. Inside each method I get remote interface of RulesManager SSB and then calls the corresponding EJB method.
    User press Update button on JSP which submits the form to another JSP. That JSP creates an instance of BankDelegate and call its updateTransactions() method.
    Each EJB method is using container managed transactions. Inside each EJB method, if anything failed then i issued a rollback using this._sessionContext.setRollbackOnly();
    I am using MS SQL Server 2000.
    Thanks

  • How to change JNDI settings for EJB, w/o BC4J

    How does one change the JNDI settings, name etc for an EJB ... without using a BC4J application module ?
    I have a simple Stateless Session Bean, I can deploy this to the database using the 'Deploy Classes To Oracle 8i' option but the bean does not show up in the 'test' JNDI context.
    From searching and reading the help files the only referrences that I can find for setting JNDI options are in the stuff reladted to application modules which are BC4J specific, I don't have a BC4J project and I don't want a BC4J project.
    Suggestions ?

    More information... I believe that the reason I do not get to change JNDI settings is because I am not choosing the 'Enterprise Java Bean (EJB) to Oracle8i' deployment type in the deployment wizard.
    The reason I don't pick it is ... because its not there !
    So, why does this option not appear in my deployment types. Could it be related to my Oracle client configuration which pre-dates my JDeveloper setup and is for an earlier version of the Oracle database ?

  • Cross-Company Sales and Billing doesn't call BUV transaction settings

    Hello Dear Experts.
    Please help me with the following issue:
    1) The Company consists of Headquater and branches (one legal entity) - several Company codes are set in the system for each unit.
    2) The Contract for deliverying goods/implementation services with the Customer is concluded by the Head Office. Let's assume it's Company Code One.
    3) The goods is delivered by the plant, which is assigned to one of the branches, that is another Company Code in the system - CC2.
    4) Our FI group customised the Transaction BUV - Clearing between company codes by the following IMG path: Financial Accounting (New)-->General Ledger Accounting (New)-->Business Transactions-->Prepare Cross-Company Code Transactions (TCode OBYA).
    Note: This customising on clearing accounts work well during material transfer between Company Codes in MM and operations within Asset Management in FI-AA.
    5) I've created a sales order in CC1. I've pointed that deliverying plant is from CC2. When the billing is posted the system doesn't take the customising from BUV transaction.
    What do you think the problem is about?
    The entry posts in FI should go as shown in the figure above.
    However right now the entries as follows:
    CC1: Debits 1210 (Receivabless); Credits 6010 (Revenues). just within Company Code 1.
    VAT is not shown both here and in the Figure.
    Thanks in advance, Please help me...
    PS: I have customised Intercompany Billing through IV Billing with Internal Customer an so on, but our FI group wants to have another schema with posting as shown in the Figure above within the one step in creating the billing document.

    I'm not familiar with Verizon wanting people to change their plans online.  We just went in to upgrade a phone and they offered to check and see if we were elligible for a discount.
    Yes, you would think she could have easily given me the credit for 6 weeks but after sitting on hold for as long as I have with this situation, when she came back and wasn't interested in checking about it, I didn't have the strength left in chasing down her supervisor to get it.  Fact is, I should have never spent that much time trying to get them to correct their error.  I'm very disappointed that after talking to as many Verizon employees as I did, no one could tell me what happened and how to fix it.  I can not be the only person that had that kind of change with that plan.
    No one has contacted me yet.  I'd be surprised it they did.
    Jennifer

  • Transaction management in EJB

    Suppose, a method in session bean is called that deals with some entity beans. I want to maintain transaction over some block of codes separately (e.g. History table has to be updated synchronously with the master table) not over the whole things in the method. How it can be done?

    Hi Kuntal,
    BMP/CMP and BMT/CMT are completely different. BMP/CMP (Bean-managed persistence/ Container-managed persistence) describes the way in which entity bean persistence is handled.
    BMT/CMT (Bean-managed transactions / Container-managed transactions) controls whether bean developer or the container is in charge of demarcating transactions.
    Entity beans can be either BMP or CMP. However, they always have CMT. It's not possible to use UserTransaction wtihin an entity bean.
    For session beans, you can use BMT and use the session bean as a facade to access your entity beans. That would give you the control you're looking for.

  • Transaction Attibutes in EJB

    How can we set the Isolation levels for Transaction in Session Beans. and as well as Entity Beans i.e. CMP

    Configure the underlying datasource and connection pools in appserver.
    -cheng

  • Default  Transaction Attribute for EJBs

    Guys,
    Can you tell me the default transaction attributes if any in Weblogic 7.0 i.e.
    the attributes used
    if not explicitly specified for a bean method when using in CMT ?
    For CMP entity beans,
    MDBs,
    Other beans (?) :
    thanks for your help
    regards
    Ved

    Hello Mr. Woollen,
    As always, thank you for your excellent insight into the internals of BEA WebLogic.
    I now have a better understanding of what happens "by default" in WLS. I do agree
    that changing this now would definitely break existing applications. It's always
    difficult to decide when to officially deprecate a "feature" or to leave it in
    forever.
    Best regards,
    Ryan LeCompte
    [email protected]
    http://www.louisiana.edu/~rml7669
    Rob Woollen <[email protected]> wrote:
    For better or worse, MDBs default to NotSupported and everything else
    defaults to Supports.
    I say for better or worse because I would have liked to change it to
    always require the user to set a default transaction attribute.
    Unfortunately we have many customer's applications who depend on this
    behavior, and I believe if we change it we will break all of them.
    Regardless, I would not recommend depending on our default tx attribute
    and instead always set one for '*'.
    In general, entity beans should run as Required or Mandatory. Session
    beans are usually required or notsupported. MDBs are required or
    notsupported.
    -- Rob
    Ved Gangaputra wrote:
    Guys,
    Can you tell me the default transaction attributes if any in Weblogic7.0 i.e.
    the attributes used
    if not explicitly specified for a bean method when using in CMT ?
    For CMP entity beans,
    MDBs,
    Other beans (?) :
    thanks for your help
    regards
    Ved

  • Manage a transaction without an EJB container !

    Hi all,
    i have a problem, i have to write into 5 tables of a DBMS launching 5 queries.
    My application is a standalone program, about your opinion how can i manage the 5 queries inside a transaction ?
    I have heard that i could use a property of the Connection class called AutoCommit.
    Any suggestion ?
    Cheers.
    Stefano

    I'd say that if the OP hasn't heard of autoCommit that
    Spring might be over his/her head. Yeah, your probably right.
    Better to learn
    how to do it with JDBC first, IMO.Definitely
    Not only will they learn about units of work, they'll
    appreciate all that a good framework is doing for them
    once they realize how much work it is to do by hand.
    %Just want to point out other solutions when they are potential fits, up to the poster to decide if its overkill for their scenario.
    Cheers,
    -Scott

Maybe you are looking for

  • How do i connect to SQL server using the JDBC ODBC

    I am attempting to connect to a database on a server over a network. It is running SQL Server 2005. Am i supposed to set the ODBC on my computer or on the server computer and this is the code i am using but i keep getting a class not found exception.

  • Memory Leak Issue

    Has anyone else noticed the Adobe Connect add-in using up large amounts of RAM ? In a 40 minute Connect meeting this morning , checking task manager the ram being used by Connectaddin.exe was 1,0035,016k , so almost 1 gig of ram. I noticed that the C

  • Graphical Shutdown Screen to text

    How do I get a text based shutdown screen instead of the current graphical one? IOW, it doesn't work. It looks like some kind of graphic is displayed on shutdown which I'm guessing is similar to the startup screen. On startup you can press escape to

  • Button change color on select, then change back

    I have 3 buttons, named but,but2,but3. What I want is if you click a button it changes color to show what page your on. But when you click a different button now that one is highlighted and the original one goes back to the original color. Here's the

  • HT2204 App Store Gift Card

    How do I add an App Store Gift card to my Apple ID Account, it's no longer listed as an option the way it was during set-up