Discussions

EJB programming & troubleshooting: VAJ 4.0 Help with SLSB accessing Entity Java Bean via AccessBean

  1. I'm currently pulling out my hair with a particular problem...I'm new to the EJB programming space, and wanted to try something 'simple' so here's the situation:

    I have 2 entity beans: Employee and Increment. The Employee bean is a CMP bean with 2 fields, ID and Name. The Increment is a rip-off of the sample increment bean that came with Visual Age for Java 4.0, and it basially has 2 persisted fields: Name and count, and 1 business method: increment() that returns the current count and adds 1.

    I'm trying to apply the session facade patters to this so I created a SLSB called EmployeeManagerSLSBean and it has a method in it called 'createEmployee(EmployeeVO)' which takes the employee data, gets the next ID from the increment bean, and sets the employee properties of the Employee entity bean. In Visual Age for Java, i created Access Beans for the Increment, Employee, and EmployeeManagerSLS beans. the createEmployee() method uses the Access Beans for Increment and Employee to perform the work of looking up contexts, etc.

    THE PROBELM:

    The database I am connecting to is MS SQL 2k using the Microsoft JDBC driver found on their website.
    I create a test client, which creates an instance of the EmployeeVO that I want to create, and the EmployeeManagerSLSAccessBean that I will use to call createEmployee(). I get the following exception:

    Caught Employee Manager Exception.
    com.immedient.employee.EmployeeManagerException: There was an exception attempting to create the employee: CORBA TRANSACTION_ROLLEDBACK 0 No; nested exception is:
    org.omg.CORBA.TRANSACTION_ROLLEDBACK: com.ibm.websphere.csi.CSITransactionRolledbackException

    Here's the transaction properties for each of the beans:
    Increment: TX_REQUIRES_NEW -- TRANSACTION_SERIALIZEABLE
    Employee: TX_REQUIRED -- TRANSACTION_SERIALIZEABLE
    EmployeeManagerSLS TX_REQUIRED -- TRANSACTION_SERIALIZEABLE

    I've actually played around with the various transaction isolation and attribures with the EmployeeManagerSLS to be TRANSACTION_READ_COMMITED,etc, but no change..the transaction keeps getting rolled back. However, the Increment bean updates are happening properly in the database, because it is set to TX_REQUIRES_NEW, that update goes through no matter what happens to the other transaction (this is how it should work, and how I want it to work).

    A SIMPLER TEST CASE:

    I changed the createEmployee() method to not use the IncrementAccessBean at all (commented out the code), and hard coded the ID that i want to use to create the employee. The transaction is STILL rolled back. Aparantly I can't use the EmployeeAccessBean inside a stateless session bean?!!? Has anyone else had this problem? it's KILLING me! Any help is appreciated! Thank you.

    -Chris
  2. Ok, got the answer:

    The employee (I lied) actually had 3 properties, first name, middle init, last name, in addition to the primary key. The primary key was a required field, but I also modled it to require the first and last name. But the AccessBean wasn't set up to allow me to create the entity by passing in those values. Ergo, the rollback was caused by a invalid column being null. I only wish it said that in the stacktrace somewhere :/.

    -Chris