Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1179940

Summary: Missing exception handling in MembeshipDAOImpl
Product: [JBoss] JBoss Enterprise Portal Platform 6 Reporter: Martin Weiler <mweiler>
Component: PortalAssignee: Peter Palaga <ppalaga>
Status: CLOSED UPSTREAM QA Contact: vramik
Severity: high Docs Contact:
Priority: high    
Version: 6.1.1CC: epp-bugs, ppalaga
Target Milestone: ER09   
Target Release: 6.2.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1180232 (view as bug list) Environment:
Last Closed: 2025-02-10 03:43:51 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Byteman rule to simulate DB exception
none
GenericJDBCException - 6.1.1.GA
none
GenericJDBCException - 6.2.0.ER9 none

Description Martin Weiler 2015-01-07 21:35:17 UTC
Description of problem:
Platform issue for GTNPORTAL-3572

MembershipDAOImpl.linkMembership(...) is missing exception handling around the following call:

  getIdentitySession().getRoleManager().createRole(mt.getName(), user.getUserName(), groupId);

If this call fails, eg. for example due to an exception from the underlying database, this result in a corrupted transaction state. Subsequent requests using this thread fail with an error similar to the following:

  org.hibernate.AssertionFailure: null id in org.picketlink.idm.impl.model.hibernate.HibernateIdentityObjectRelationship entry (don't flush the Session after an exception occurs)


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 2 Martin Weiler 2015-01-08 13:17:37 UTC
Steps to reproduce the error, and test a fix:

1. Start JPP 6
2. Login as root and create:
   - a new group /platform/test
   - a new user demo (only assigned to /platform/users)
3. Stop the server
4. Edit standalone.xml:

                <security-domain name="gatein-domain" cache-type="default">
                    <authentication>
                         <login-module code="org.exoplatform.web.security.InitSharedStateLoginModule" flag="required">
                            <module-option name="portalContainerName" value="portal"/>
                            <module-option name="realmName" value="gatein-domain"/>
                         </login-module>
                         <login-module code="org.exoplatform.services.security.jaas.SharedStateLoginModule" flag="required">
                            <module-option name="portalContainerName" value="portal"/>
                            <module-option name="realmName" value="gatein-domain"/>
                         </login-module>
                          <login-module code="org.exoplatform.services.organization.idm.CustomMembershipLoginModule" flag="required">
                            <module-option name="portalContainerName" value="portal"/>
                            <module-option name="realmName" value="gatein-domain"/>
                            <module-option name="membershipType" value="member"/>
                            <module-option name="groupId" value="/platform/test"/>
                          </login-module> 
                        <login-module code="org.exoplatform.services.security.j2ee.JBossAS7LoginModule" flag="required">
                            <module-option name="portalContainerName" value="portal"/>
                            <module-option name="realmName" value="gatein-domain"/>
                        </login-module>
                    </authentication>
                </security-domain>

5. Start the server
6. Install byteman against the JPP pid
7. Submit the attached byteman rules. This will simulate a DB error during CustomMembershipLoginModule.addUserToPlatformUsers
8. Log in as user 'demo'

Without the fix for GTNPORTAL-3572, the exception will not be handled properly in MembershipDAOImpl. This leads to the following:

* JPP 6.1.1 / GateIn 3.6:
An Identity operation error is logged:
Caused by: org.hibernate.TransactionException: nested transactions not supported
The user is not logged in, and further requests using this thread are broken.

* JPP 6.2 / GateIn 3.8:
IDM error recovery is happening on CustomMembershipLoginModule.end -> PicketLinkIDMOrganizationServiceImpl.endRequest. Further requests using this thread are handled properly. Nevertheless, proper exception handling inside MembershipDAOImpl is better instead of waiting on the lifecycle end method to clean up the transaction.

Comment 3 Martin Weiler 2015-01-08 13:20:13 UTC
Created attachment 977804 [details]
Byteman rule to simulate DB exception

Comment 4 Peter Palaga 2015-02-24 15:07:46 UTC
https://github.com/gatein/gatein-portal/pull/925 was merged in upstream

Comment 5 Tomas Kyjovsky 2015-03-17 15:40:29 UTC
Martin, I get the same exception for 6.2.0.ER9 and 6.1.1.GA with your byteman script, but it's different from what you wrote in Comment 2:

...
org.hibernate.exception.GenericJDBCException: could not insert
...

Comment 6 Tomas Kyjovsky 2015-03-17 15:41:35 UTC
Created attachment 1002845 [details]
GenericJDBCException - 6.1.1.GA

Comment 7 Tomas Kyjovsky 2015-03-17 15:41:55 UTC
Created attachment 1002846 [details]
GenericJDBCException - 6.2.0.ER9

Comment 8 Tomas Kyjovsky 2015-03-17 15:42:29 UTC
Btw, the GenericJDBCException already appears during portal startup. I never get to the demo login part.

Comment 9 Martin Weiler 2015-03-17 16:03:28 UTC
Tomas,

are you starting JPP with the byteman script already? The steps to follow should be:

- start JPP to create a new group and user, stop JPP again
- edit standalone.xml to add the CustomMembershipLoginModule with the new group
- start JPP again (no byteman)
- after JPP has started, install the byteman rule
- try to log in with the new test user (not yet assigned to the new group)

HTH,
Martin

Comment 10 Tomas Kyjovsky 2015-03-17 16:05:26 UTC
Looks like I missed few steps, sorry. I will retest.

Comment 11 vramik 2015-03-18 16:27:00 UTC
I've retested and I get the same stacktrace as Tomas (https://bugzilla.redhat.com/attachment.cgi?id=1002846). According to IRC conversation with Martin, the db exception is handeles and the issue can be cosidered as fixed, so I'm changing status to verified.

Comment 13 Red Hat Bugzilla 2025-02-10 03:43:51 UTC
This product has been discontinued or is no longer tracked in Red Hat Bugzilla.