12 Replies Latest reply: Nov 19, 2012 9:01 AM by Rafael Peres dos Santos RSS

Transaction propagation doesn't work

Alex Bogoley Newbie

Hello!

I have some troubles with transactions on JBOSS AS 7.  When I call from my EmployerDAO some methods of other EJBs it usually results in deadlock on DB2 database.

I can't understand the reason, as all logic should be executed in one transaction - but unfortunatly deadlocks appears.

I have attached my persistence xml.


my datasource configuration in JBOSS:

 

 <xa-datasource jndi-name="java:/jdbc/BS" pool-name="BS" enabled="true" use-java-context="true" use-ccm="true">
                    <xa-datasource-property name="DatabaseName">
                        DEMO45N2
                    </xa-datasource-property>
                    <xa-datasource-property name="ServerName">
                        192.168.32.40
                    </xa-datasource-property>
                    <xa-datasource-property name="PortNumber">
                        50001
                    </xa-datasource-property>
                    <xa-datasource-property name="DriverType">
                        4
                    </xa-datasource-property>
                    <xa-datasource-class>com.ibm.db2.jcc.DB2XADataSource</xa-datasource-class>
                    <driver>org.db2</driver>
                    <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
                    <xa-pool>
                        <max-pool-size>8</max-pool-size>
                        <prefill>false</prefill>
                        <use-strict-min>false</use-strict-min>
                        <flush-strategy>FailingConnectionOnly</flush-strategy>
                        <pad-xid>false</pad-xid>
                        <wrap-xa-resource>false</wrap-xa-resource>
                    </xa-pool>
                    <security>
                        <user-name>db2inst1</user-name>
                        <password>asdf</password>
                    </security>
                    <validation>
                        <validate-on-match>false</validate-on-match>
                        <background-validation>false</background-validation>
                        <background-validation-millis>1</background-validation-millis>
                        <use-fast-fail>false</use-fast-fail>
                    </validation>
                    <statement>
                        <prepared-statement-cache-size>0</prepared-statement-cache-size>
                    </statement>
                </xa-datasource>

 

My code :

 


@Stateless(name = "employerDAO")
@Local(value = EmployerDAO.class)
public class EmployerDAOImpl extends BaseDAOImpl<Employer> implements EmployerDAO {

@EJB
private EmployeeDAO employeeDAO;
@EJB
private SubgroupDAO subgroupDAO;


.....
@Override
public void changeStatus(long employerId, OrganizationStatus status,EmployeeStatus employeeStatus, String reason) {
subgroupDAO.changeStatusOfOrganizationSubgroups(status, employerId);
employeeDAO.changeStatusOfOrganizationEmployees(employeeStatus, employerId);
Employer employer = getEntityManager().find(Employer.class, employerId);
employer.setStatus(status);
employer.setStatusReason(reason);
employer.setStatusDate(new Date());
}

....
}

Is that is bug ? Thanks for response.