Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabled fields and multiple-inherence (override once => override for sub-classes) #871

Closed
Tomas-Kraus opened this issue Dec 1, 2011 · 21 comments

Comments

@Tomas-Kraus
Copy link
Member

I've been running with an issue caused by the checkOverrideProperties() method which has been added in JAXB 2.2, so I've only been running with this issue since I upgraded the JAXB library in my application..

I'll just give an example, and I think this should be understandable.

Here is my model:

public abstract class Parent {
    private String element1;
    private String element2;

    public String getElement1() {
        return element1;
    }

    public void setElement1(String element1) {
        this.element1 = element1;
    }

    public String getElement2() {
        return element2;
    }

    public void setElement2(String element2) {
        this.element2 = element2;
    }
}

@XmlRootElement(name = "child1")
@XmlAccessorType(XmlAccessType.FIELD)
public class Child1 extends Parent {
    private String element1;
    private String element3;

    public String getElement1() {
        return element1;
    }

    public void setElement1(String element1) {
        this.element1 = element1;
    }

    public String getElement3() {
        return element3;
    }

    public void setElement3(String element3) {
        this.element3 = element3;
    }
}

@XmlRootElement(name = "child2")
@XmlAccessorType(XmlAccessType.FIELD)
public class Child2 extends Parent
{
    private String element4;

    public String getElement4() {
        return element4;
    }

    public void setElement4(String element4) {
        this.element4 = element4;
    }
}

@XmlRootElement(name = "wrapper")
@XmlAccessorType(XmlAccessType.FIELD)
public class Wrapper
{
    private Child1 child1;
    private Child2 child2;

    public Child1 getChild1() {
        return child1;
    }

    public void setChild1(Child1 child1) {
        this.child1 = child1;
    }

    public Child2 getChild2() {
        return child2;
    }

    public void setChild2(Child2 child2) {
        this.child2 = child2;
    }
}

Here is the instance of my model:

final Child1 child1 = new Child1();
child1.setElement1("element1-1");
child1.setElement2("element1-2");
child1.setElement3("element1-3");

final Child2 child2 = new Child2();
child2.setElement1("element2-1");
child2.setElement2("element2-2");
child2.setElement4("element2-4");

final Wrapper wrapper = new Wrapper();
wrapper.setChild1(child1);
wrapper.setChild2(child2);

Using JAXB 2.2.4 or 2.2.4-1 to marhsall the objects, I get the following XML :

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<wrapper>
	<child1>
		<element2>element1-2</element2>
		<element1>element1-1</element1>
		<element3>element1-3</element3>
	</child1>
	<child2>
		<element2>element2-2</element2>
		<element4>element2-4</element4>
	</child2>
</wrapper>

As you can see the child2 element minus the element1 subitem. This is because the child1 inherence disabled element1 in parent. Disabling it for child1 is okay, but I don't think it should be disabled for child2 as well.

The easiest workaround is to avoid any override in the java model.

Thank you for your interest.

Affected Versions

[2.2.4, 2.2.4u1]

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
Reported by guinotphil

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
Was assigned to snajper

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
snajper said:
This has been introduced with 804 fix, agree it does not work properly. Since there are voices seeing this as a regression even if the child2 property would not be hidden as expected, I think the best solution is to revert this back to the original behaviour, improve the fix and bind it to a switch. I don't want to remove the fix completely because this is closer to what moxy does as well.

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
snajper said:
Fixed in 22 branch.

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
Marked as fixed on Wednesday, May 23rd 2012, 4:43:02 am

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
File: op1_Response.xml
Attached By: gezr

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
File: op2_Response.xml
Attached By: gezr

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
File: SampleService.wsdl
Attached By: gezr

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
File: SampleService_with_override.wsdl
Attached By: gezr

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
gezr said:
Added sample web service to reproduce the problem:

Steps to reproduce:

  • Uncomment getDate()/setDate(Date) methods in the DerivedObj1.java class
  • Compile and run service

The difference will be on the response to the SampleService#op2 method call from which ns2:date field disappears:

  • Before override:```
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    soap:Body


    ns2:date2012-07-18T18:10:43.235+02:00</ns2:date>
    ns2:nameDerived 2</ns2:name>
    ns2:time1342627843239</ns2:time>


    </soap:Body>
    </soap:Envelope>
    
    
  • After override in DerivedObj1:```
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    soap:Body


    ns2:nameDerived 2</ns2:name>
    ns2:time1342628337325</ns2:time>


    </soap:Body>
    </soap:Envelope>
    
    

Environment:

  • Java:```
    java version "1.7.0_05"
    Java(TM) SE Runtime Environment (build 1.7.0_05-b05)
    Java HotSpot(TM) Client VM (build 23.1-b03, mixed mode, sharing)

    
    
  • JAXB:```
    jdk1.7.0_05\bin>wsgen -version
    JAX-WS RI 2.2.4-b01

    jdk1.7.0_05\bin>xjc -version
    xjc 2.2.4

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
File: op1_Response_with_override.xml
Attached By: gezr

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
File: op2_Response_with_override.xml
Attached By: gezr

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
File: BaseObj.java
Attached By: gezr

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
File: DerivedObj1.java
Attached By: gezr

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
File: DerivedObj2.java
Attached By: gezr

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
File: package-info.java
Attached By: gezr

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
File: SampleService.java
Attached By: gezr

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
File: SampleServiceImpl.java
Attached By: gezr

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
gezr said:
I understand that the issue was already fixed in 2.2.6 which as far as I know was not released yet. However what bothers me more is that in JDK 7 (up to update 5) the JAXB distribution is still broken. So I have couple of concerns:

  • Will the fix be back-ported to 2.2.4 version?
  • When the fix will be released?
  • Will the fix be included in JDK 7?
  • When such a fix could be included in JDK 7 distribution?

The reason for the JDK 7 question is because we have recently converted project from Java 6 to Java 7 and now we hit this bug. For us it is a blocker for a delivery of our product.

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
This issue was imported from java.net JIRA JAXB-871

@Tomas-Kraus
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants