container/profiles/src/main/java/org/mobicents/slee/container/profile/AbstractProfileMBeanImpl.java
public void commitProfile() throws InvalidStateException, ProfileVerificationException, ManagementException {

        if (logger.isDebugEnabled()) {
            logger.debug("commitProfile() on: " + profileName + ", from table:" + profileTable.getProfileTableName());
        }

        if (!this.isProfileWriteable())
            throw new InvalidStateException("not in write state");

        final SleeTransactionManager txManager = sleeContainer.getTransactionManager();

        ProfileEntity profileEntity = null;

        try {

            // resume tx
            txManager.resume(this.transaction);

            // verify state
            ProfileObjectImpl profileObject = getProfileObject();
            profileObject.profileVerify();

            // check if the tx is marked for rollback
            if (txManager.getRollbackOnly()) {
                // FIXME can't undertsand why the rollback and change of state, perhaps tests/profiles/lifecycle/Test1110227Test.xml is faulty??
                // FIXME: Do we need to close EntityManager here?
                EntityManager em = getEntityManager(txManager);
                txManager.rollback();
                if (em != null && em.isOpen()) {
                    em.close();
                }
                readMode();
                this.transaction = null;
                throw new RollbackException("the tx is marked for rollback, can't proceeed with commit");
            }

            // "save" profile entity, we may need to recover its current state
            profileEntity = profileObject.getProfileEntity();

            // commit tx
            this.transaction = null;
            txManager.commit();

            // change mode
            readMode();

        } catch (ProfileVerificationException e) {
            if (logger.isDebugEnabled()) {
                logger.debug(e.getMessage(), e);
            }
            throw e;
        } catch (RollbackException e) {
            if (logger.isDebugEnabled()) {
                logger.debug(e.getMessage(), e);
            }
            if (e.getCause() instanceof PersistenceException && e.getCause().getCause() instanceof ConstraintViolationException) {
                throw new ProfileVerificationException(e.getCause().getMessage(), e);
            } else if (e.getCause() != null && e.getCause().getClass() == Throwable.class && e.getCause().getMessage() != null && e.getCause().getMessage().equals("setRollbackOnly called from:")) {
                // workaround for issue with jboss AS 5.1.0 GA / Hibernate Entity Manager 3.4.0.GA / JBoss TS 4.6.1.GA, the persistentexception is not thrown
                throw new ProfileVerificationException(e.getCause().getMessage(), e);
            } else {
                throw new ManagementException(e.getMessage(), e);
            }
        } catch (Throwable e) {
            if (logger.isDebugEnabled()) {
                logger.debug(e.getMessage(), e);
            }
            throw new ManagementException(e.getMessage(), e);

        } finally {
            if (this.transaction == null) {
                if (isProfileWriteable()) {
                    // still in write mode
                    if (logger.isDebugEnabled()) {
                        logger.debug("The tx commit failed, recreating tx with current profile entity state");
                    }
                    try {
                        txManager.begin();
                        this.transaction = txManager.getTransaction();
                        ProfileEntity newTxProfileEntity = profileEntity.isCreate() ? profileTable.createProfile(profileName).getProfileEntity() : getProfileObject().getProfileEntity();
                        profileTable.getProfileSpecificationComponent().getProfileEntityFramework().getProfileEntityFactory().copyAttributes(profileEntity, newTxProfileEntity);
                        newTxProfileEntity.setReadOnly(false);
                        txManager.suspend();
                    } catch (Throwable e) {
                        throw new ManagementException(e.getMessage(), e);
                    }
                }
            } else {
                // tx still valid
                try {
                    txManager.suspend();
                } catch (Throwable f) {
                    logger.error(f.getMessage(), f);
                }
            }
        }
    }
public void commitProfile() throws InvalidStateException, ProfileVerificationException, ManagementException {

        if (logger.isDebugEnabled()) {
            logger.debug("commitProfile() on: " + profileName + ", from table:" + profileTable.getProfileTableName());
        }

        if (!this.isProfileWriteable())
            throw new InvalidStateException("not in write state");

        final SleeTransactionManager txManager = sleeContainer.getTransactionManager();

        ProfileEntity profileEntity = null;

        try {

            // resume tx
            txManager.resume(this.transaction);

            // verify state
            ProfileObjectImpl profileObject = getProfileObject();
            profileObject.profileVerify();

            // check if the tx is marked for rollback
            if (txManager.getRollbackOnly()) {
                // FIXME can't undertsand why the rollback and change of state, perhaps tests/profiles/lifecycle/Test1110227Test.xml is faulty??
                // FIXME: Do we need to close EntityManager here?
                EntityManager em = getEntityManager(txManager);
                txManager.rollback();
                if (em != null && em.isOpen()) {
                    em.close();
                }
                readMode();
                this.transaction = null;
                throw new RollbackException("the tx is marked for rollback, can't proceeed with commit");
            }

            // "save" profile entity, we may need to recover its current state
            profileEntity = profileObject.getProfileEntity();

            // commit tx
            this.transaction = null;
            txManager.commit();

            // change mode
            readMode();

        } catch (ProfileVerificationException e) {
            if (logger.isDebugEnabled()) {
                logger.debug(e.getMessage(), e);
            }
            throw e;
        } catch (RollbackException e) {
            if (logger.isDebugEnabled()) {
                logger.debug(e.getMessage(), e);
            }
            if (e.getCause() instanceof PersistenceException && e.getCause().getCause() instanceof ConstraintViolationException) {
                throw new ProfileVerificationException(e.getCause().getMessage(), e);
            } else if (e.getCause() != null && e.getCause().getClass() == Throwable.class && e.getCause().getMessage() != null && e.getCause().getMessage().equals("setRollbackOnly called from:")) {
                // workaround for issue with jboss AS 5.1.0 GA / Hibernate Entity Manager 3.4.0.GA / JBoss TS 4.6.1.GA, the persistentexception is not thrown
                throw new ProfileVerificationException(e.getCause().getMessage(), e);
            } else {
                throw new ManagementException(e.getMessage(), e);
            }
        } catch (Throwable e) {
            if (logger.isDebugEnabled()) {
                logger.debug(e.getMessage(), e);
            }
            throw new ManagementException(e.getMessage(), e);

        } finally {
            if (this.transaction == null) {
                if (isProfileWriteable()) {
                    // still in write mode
                    if (logger.isDebugEnabled()) {
                        logger.debug("The tx commit failed, recreating tx with current profile entity state");
                    }
                    try {
                        txManager.begin();
                        this.transaction = txManager.getTransaction();
                        ProfileEntity newTxProfileEntity = profileEntity.isCreate() ? profileTable.createProfile(profileName).getProfileEntity() : getProfileObject().getProfileEntity();
                        profileTable.getProfileSpecificationComponent().getProfileEntityFramework().getProfileEntityFactory().copyAttributes(profileEntity, newTxProfileEntity);
                        newTxProfileEntity.setReadOnly(false);
                        txManager.suspend();
                    } catch (Throwable e) {
                        throw new ManagementException(e.getMessage(), e);
                    }
                }
            } else {
                // tx still valid
                try {
                    txManager.suspend();
                } catch (Throwable f) {
                    logger.error(f.getMessage(), f);
                }
            }
        }
    }
/*
(non-Javadoc)
@see javax.slee.profile.ProfileMBean#commitProfile()

This method commits profile. See descritpion - profile becomes visible for slee ONLY when its commited.