Debugging "java.lang.IllegalStateException: Duplicate component id" error

I recently noticed an issue reported with below stack trace. Here the run time complaints about the presence of duplicate id in the jsf page. Interestingly, none of the components used in the page shares the same id. So what goes wrong here?

java.lang.IllegalStateException: Duplicate component id: 'pt1:USma:0:MAnt1:0:pt1:Perio1:0:ap1:r9:requestBtns:localeView:si1', first used in tag: 'com.sun.faces.taglib.jsf_core.SelectItemsTag'
+id: j_id__ctru0
  type: javax.faces.component.UIViewRoot@53eff13
   +id: doc1
    type: RichDocumentUIXFacesBeanImpl, id=doc1
     +id: pt1
      type:$ContextualFacesBeanWrapper@4bcc1b1, id=pt1
       +id: r1
        type: RichRegionUIXFacesBeanImpl, id=r1
         +id: p1
          type: RichPopupUIXFacesBeanImpl, id=p1
           +id: dia1

Let me share a couple of points which may help you to narrow down this issue.

1. If you use multiple instances of same task flow in a page, please make sure that you define separate binding for each task flow. This is really needed as each task flow instance needs to live in their own world.

Wrong Implementation:
<af:region value="#{bindings.myTaskflowdefinition1.regionModel}"
<af:region value="#{bindings.myTaskflowdefinition1.regionModel}"
Correct Implementation:
<af:region value="#{bindings.myTaskflowdefinition1.regionModel}"
<af:region value="#{bindings.myTaskflowdefinition2.regionModel}"
2. While building a task flow, please make sure that scope specified for manged bean is not visible from another instances of the same task flow. This means that backingBean, view and pageFlow may be the right 'scope' choices depending on your use case requirement. Please avoid request, session and application scopes unless you have specific reason for that.
Why? The issue is that, in some cases you may need to access the UI component from manged bean and apparently you may go for binding the component with bean. Here, if you chose a scope which is visible from another instances of the same task flow, that may cause unpredictable behavior later and may result in the above said error as well.

Please go through chapter 14.2.4 What You May Need to Know About Memory Scope for Task Flows from Oracle® Fusion Middleware Fusion Developer's Guide to learn more.


Post a Comment


The views expressed on this blog are my own and do not necessarily reflect the views of my employer.