0

migrating weblogic 10.3.0 server (used java 6 ,jsf framework (Mojarra-2.1.7) and (maven-based) worked totally fine) to weblogic 12c server and also java 6 to java 8 since then having issues of duplicate id in whichever views are using component binding attribute.All managed beans are session scoped and some beans are shared by different views while navigation from one to other.

I have tried replacing the already used jsf jars(Mojarra-2.1.7) to (Mojarra-2.2.2) and javax.faces/javax.faces.api.jar(Mojarra-2.3).Removing binding from jsf components in xhtml and session scopes from the beans doesn't throw duplicate id error but i cannot do that (for a reason). i have read almost every post about id duplication error and this JSF spec- JSF 2.0 spec section 3.1.5 "... It is strongly recommend that application developers place managed beans that are pointed at by component binding expressions in “request” scope, and not any other scope. This is because placing it in session or application scope would require threadsafety, since UIComponent instances depends on running inside of a single thread. There are also potentially negative impacts on memory management when placing a component binding in “session” or “view” scopes.

Just wondering if it had been about bean's scope then this error should have happened with previous weblogic 10.3 and jsf 2.1.7 version as well but it never did.Could it be becoz of the weblogic 12c or java8 or jsf version ??

Component tree :

  +id: checkDt
               type: org.primefaces.component.datatable.DataTable@6f454948
                +id: ColHeader1  <===============
                 type: org.primefaces.component.column.Column@2efbb3b1
                  +id: j_idt98
                   type: javax.faces.component.html.HtmlOutputText@14cbcb4
                  +id: j_idt99
                   type: org.primefaces.component.selectbooleancheckbox.SelectBooleanCheckbox@1025f970
                +id: Col2
                 type: org.primefaces.component.column.Column@556fed35
                  +id: Name
                   type: javax.faces.component.html.HtmlOutputLabel@267aaa12
                    +id: j_idt100
                     type: org.primefaces.component.tooltip.Tooltip@42370b75
                +id: Col3
                 type: org.primefaces.component.column.Column@7d66943a
                  +id: reasonText
                   type: org.primefaces.component.inputtext.InputText@57cac8e6
                +id: ColHeader1  <===============
                 type: org.primefaces.component.column.Column@2493d237
                  +id: j_idt98
                   type: javax.faces.component.html.HtmlOutputText@5e051973
                  +id: j_idt99
                   type: org.primefaces.component.selectbooleancheckbox.SelectBooleanCheckbox@170b81cd
                +id: Col2
                 type: org.primefaces.component.column.Column@1687f632
                  +id: Name
                   type: javax.faces.component.html.HtmlOutputLabel@2c3f9cbf
                    +id: j_idt100
                     type: org.primefaces.component.tooltip.Tooltip@5a07c6ca
                +id: Col3
                 type: org.primefaces.component.column.Column@114921ae
                  +id: reasonText
                   type: org.primefaces.component.inputtext.InputText@385673d3
        +id: j_idt101
         type:

.xhtml file :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">

<h:body>
            <h:form id="New">
            <p:dataTable id="checkDt" var="check" rowIndexVar="rowIndex"                                    
                                value="#{requestBean.requestVOList}"
                                binding="#{requestBean.ListDT}"     <!-binding is used in parent comp -datatable so all the child component ids are repeated in tree-!>                     
                                style="width:90%">

                                <p:column id="ColHeader1" styleClass="TEXT-ALIGN-CENTER"
                                    style="white-space:normal;text-align:center;width:130px;">
                                    <f:facet name="header">
                                        <h:outputText
                                            value="header 1"></h:outputText>
                                    </f:facet>
                                    <p:selectBooleanCheckbox value="#{check.selectedCheckBox}"
                                        disabled="true">

                                    </p:selectBooleanCheckbox>
                                </p:column>

                                <p:column id="Col2"
                                    headerText="header 2">
                                    <h:outputLabel id="Name" value="#{check.nameShort}">
                                        <p:tooltip for="Name" value="#{check.nameShort}"></p:tooltip>
                                    </h:outputLabel>
                                </p:column>

                                <p:column id="Col3"
                                    headerText="header 3">
                                    <p:inputText id="reasonText" value="#{check.reason}"
                                        autocomplete="off" disabled="true"></p:inputText>
                                </p:column>

                            </p:dataTable>
                        </h:form>   
</h:body>   
</html>             

bean :

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.component.UIData;


@ManagedBean
@SessionScoped
public class RequestBean {

private RequestVO requestVO = null;  // a seperate class (or model) having       its property variables and getter setters like selectedCheckBox(boolean),nameShort, reason (Strings)
private List<RequestVO > requestVOList; 
private UIData listDT = null;




public List<RequestVO> getRequestVOList() {
    return requestVOList;
}

public void setRequestVOList(List<RequestVO > list) {
    this.requestVOList= list;
}

public UIData getListDT() {
    return listDT;
}

public void setListDT(UIData listDT) {
    this.listDT = listDT;
}

}

RequestVO.java :

public class RequestVO{

private boolean selectedCheckBox = false;
private String nameShort=null;
private String reason=null;

public boolean isSelectedCheckBox() {
    return selectedCheckBox;
}

public void setSelectedCheckBox(boolean selectedCheckBox) {
    this.selectedCheckBox = selectedCheckBox;
}

public String getNameShort() {
    return nameShort;
}

public void setNameShort(String nameShort) {
    this.nameShort = nameShort;
}

public String getReason() {
    return reason;
}

public void setReason(String reason) {
    this.reason = reason;
}






}

POM:

 <dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.2.2</version>
 <scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.2.2</version>
 <scope>provided</scope>
</dependency>
  • 1
    Please reduce and improve the code in your question to make it an [mcve]. And previous versions might have had a bug that was 'masked' and only now manifests itself. And 'com.gbis' for the package of the JSF impl and API is sort of not common! What is it? And assigining explicit ID's makes debugging easier btw – Kukeltje Jan 15 '19 at 12:10
  • Have reduced the code. I never got this issue in my existing working jsf application that used weblogic 10.3.0 server, java 6 ,jsf-api /jsf-impl (2.1.7) and primefaces-4.0 and beans also were session scoped only after migrating to weblogic 12c and java 8 , this happened. That groupID in POM was for my local workspace setup, i have edited it to " javax.faces" (to avoid confusion) – Mohd Yusuf Jan 15 '19 at 13:25
  • Thank you for reducing the code. But reduction is not enough to make it an [mcve]. I cannot try to copy/paste this locally and run it. See also https://www.stackoverflow.com/tags/jsf/info. And you use a PrimeFaces datatable. Is that relevant or does it also fail with a plain `h:datatable`? And with one less column? Or even with a `ui:repeat` or with a non-repeating component? So you can reduce more and make it more complete and executable. And please also post JSF version info in the question (is that still the 4.0 version? Tried a newer one (just for this problem)? – Kukeltje Jan 15 '19 at 13:33
  • I somehow managed to make it minimal, Sorry if i still couldnt make it. I hope this helps you to have an understanding of what it is doing. Primefaces datatble is used everywhere so wanted a workaround with this only. And i think its not bcoz of primefaces as binding attribute is causing this issue whether i use it on datatable or some other component. I have edited the JSF version in the post. R u saying about primefaces version - 4.0??? – Mohd Yusuf Jan 16 '19 at 09:42
  • requestBean is missing and RequestVO is as well... – Kukeltje Jan 16 '19 at 10:05
  • Sorry for that , i actually purposely didnt added that but had added a comment instead. they are actually modidfied codes similar to what i am having currently.I have added all. Now its complete i guess ?? – Mohd Yusuf Jan 16 '19 at 11:24
  • Yes but the renaming of Test to RequestBean made the real cause visible. Check https://stackoverflow.com/questions/2101755/binding-attribute-causes-duplicate-component-id-found-in-the-view. It is a duplicate of your question – Kukeltje Jan 16 '19 at 12:49
  • Thanks but i have already gone through it , didnt find any workaround for my case. That class name "Test" i mistakenly changed for pasting here . In the application all the nomenclature of beans are totally fine. Already mentioned in the post this is from an already working application with weblogic 10.3 but with weblogic 12.2.1 in same code component binding is causing duplicate id error. – Mohd Yusuf Jan 16 '19 at 13:23
  • Thanks for mentioning upfront you already went trough it (as requested in [ask] that the suggestions in there did not help. But if you did, why did you not change the `@SessionScoped` to `@RequestScoped` anyway as suggested in there (and in the references in there)? – Kukeltje Jan 16 '19 at 14:24
  • I cant change scopes bcoz almost all beans are session scoped only and changing them all might get me into some other trouble. If bean scopes would have been causing this issue then my question is why the same beans with session scoped never threw this errror previously with weblogic 10.3 and Java 6. – Mohd Yusuf Jan 17 '19 at 05:25
  • See https://stackoverflow.com/questions/22236093/duplicate-id-error-with-updated-mojarra-2-1-27. So it ,might very well ne related to something else that got fixed and you were just lucky you could use it the way ot was. Better ro bite the apple.and at the same time switch to cdi managed beans and mojarra 2.2.12 by overriding the jsf impl in weblogic – Kukeltje Jan 17 '19 at 07:42
  • @Kukeltje ," switch to cdi managed beans and mojarra 2.2.12 by overriding the jsf impl in weblogic" , pardon but can you plz elaborate this line as to how or share some links which i can go through. i am a beginner in jsf. And thanks a lot for having time to answer my queries :) – Mohd Yusuf Jan 18 '19 at 08:36
  • Using CDI `@Named` managed beans instead of JSF `@ManagedBean` managed beans is easily to find via a searchenging. How to override (upgrade) the JSF version in Weblogic is is unknow to me. I know it can be done in a not to complex way but I don't use Weblogic, so sorry. – Kukeltje Jan 18 '19 at 10:05

0 Answers0