Description of problem: If you configure a richfaces portlet in dashboard template, the portlet may break for the first access by a newly created user. Version-Release number of selected component (if applicable): 6.1.1.ER01 How reproducible: Not always (once in a few tries). You can constantly reproduce it by using debugger. Steps to Reproduce: [easy test] 1. Build and deploy jsf2-rf4-hello-world-portlet quickstart 2. Edit gatein/gatein.ear/portal.war/WEB-INF/conf/portal/user/template/user/pages.xml <page-set xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_5 http://www.gatein.org/xml/ns/gatein_objects_1_5" xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_5"> <!-- The default dashboard page --> <page> <name>Tab_Default</name> <title>Tab_Default</title> <portlet-application> <portlet> <application-ref>jsf2-rf4-hello-world-portlet</application-ref> <portlet-ref>jsf2Rf4HelloWorldPortlet</portlet-ref> <preferences/> </portlet> <access-permissions>Everyone</access-permissions> <show-info-bar>false</show-info-bar> <show-application-state>true</show-application-state> </portlet-application> </page> </page-set> 3. Start JPP 4. Login as root 5. [Application Registry]->[Import applications] 6. Create a user (e.g. john) 7. Logout 8. Login as john 9. Access to Dashboard Actual results: - You will see the following ERROR message in server side 11:15:18,639 ERROR [exo.jcr.component.core.JDBCStorageConnection] (http-/127.0.0.1:8080-5) Node add. Database error: org.h2.jdbc.JdbcSQLException: Unique index or primary key violation: "JCR_IDX_IPSYSTEM_PARENT ON PUBLIC.JCR_IPSYSTEM(PARENT_ID, NAME, I_INDEX, I_CLASS, VERSION DESC)"; SQL statement: insert into JCR_IPSYSTEM (ID, PARENT_ID, NAME, VERSION, I_CLASS, I_INDEX, N_ORDER_NUM) VALUES(?,?,?,?,1,?,?) [23505-168] or 12:01:40,837 ERROR [org.exoplatform.portal.config.NewPortalConfigListener] (http-/127.0.0.1:8080-4) An Exception occured when creating the Portal Configuration. Exception message: Attempt to insert context EntityContext[state=ObjectStatus[status=TRANSIENT],mapper=EntityMapper[class=class org.gatein.mop.core.api.workspace.UserSite,typeName=mop:usersite]] as an existing child with name mop:cccc child of node /production/mop:workspace/mop:usersites: org.chromattic.api.DuplicateNameException: Attempt to insert context EntityContext[state=ObjectStatus[status=TRANSIENT],mapper=EntityMapper[class=class org.gatein.mop.core.api.workspace.UserSite,typeName=mop:usersite]] as an existing child with name mop:cccc child of node /production/mop:workspace/mop:usersites - You will see that a select box is broken in the portlet (See dashboard_issue_01.png) - If you refresh the browser, the portlet will be recovered but then you will see a popup "This portlet does not exist anymore, please refresh your browser" (See dashboard_issue_02.png). Kinda weird. Expected results: Dashboard and its portlet are displayed without an issue Additional info: [test with a debugger] After step 8 in "Steps to Reproduce:", - Set breakpoints at: -- org.exoplatform.portal.application.PortalRequestHandler [line: 217] - processRequest(PortalRequestContext, PortalApplication) -- org.exoplatform.portal.application.UserSiteLifeCycle [line: 68] - onStartRequest(Application, PortalRequestContext) - Access to Dashboard - The first request (Thread A) stops at UserSiteLifeCycle line 68. DataStorage cannot find PortalConfig so UserPortalConfigService.createUserSite() is called. It should persist the PortalConfig to JCR but *it's not committed yet*. - Resume Thread A with debugger - Thread A stops at PortalRequestHandler line 217. Portal responded to browser but JCR is not committed yet. - Several requests (Thread B, C,...) from browser come into UserSiteLifeCycle line 68. Then "Step Over" Thread B to proceed 1 line. DataStorage cannot find PortalConfig yet and returns null so UserPortalConfigService.createUserSite() will be called. - Resume Thread A with debugger - Turn off all breakpoints - Resume all threads with debugger
Created attachment 856908 [details] dashboard_issue_01.png
Created attachment 856909 [details] dashboard_issue_02.png
As I explained in "Additional info:", the root problem seems that Portal responds to browsers before JCR commit. To fix this particular issue, delaying (or letting wait for a lock) the subsequent threads would help. Richfaces is not a mandatory condition but it sends multiple accesses for the first access so it's convenient to reproduce. Thanks to https://issues.jboss.org/browse/GTNPORTAL-2072 , we don't see NoSuchDataException in RHJP 6.1.1.ER01 but still have this issue.
As I still cannot reproduce, nor QA, I sent a patched JAR to Toshiya by email, to see if this fixes the issue. If so, I'll send a PR with the change, which is a similar solution as for BZ 1080249 .
PR sent, as Toshiya confirmed that the fix seems to work: https://github.com/gatein/gatein-portal/pull/866
https://github.com/gatein/gatein-portal/pull/866 was merged in upstream
I couldn't reproduce the issue on 6.1.1.ER1 or 6.2.0.ER3 with or without debugger.
Created attachment 908593 [details] debugger log 6.2.0.ER3
Juraci Paixão Kröhling <jpkroehling> updated the status of jira GTNPORTAL-3497 to Closed
This product has been discontinued or is no longer tracked in Red Hat Bugzilla.