Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6237813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:05:59+00:00 2026-05-24T11:05:59+00:00

I am having the following hierarchy: public class Small { private String xmlId; @XmlID

  • 0

I am having the following hierarchy:

public class Small {
    private String xmlId;

    @XmlID
    @XmlAttribute
    public String getXmlId() {
        if (xmlId == null)
            xmlId = "small" + new Random().nextInt();
        return xmlId;
    }

    public void setXmlId(String id) {
        this.xmlId = id;
    }
}

public class Big extends Small {
    // Code
}

Where I am trying to marshal the class Baz:

@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
public class Baz {
    private List<Small> smalls = new LinkedList<Small>();

    private Small small;
    private Big big;

    @XmlIDREF
    public Small getSmall() {
        return small;
    }

    public void setSmall(Small small) {
        this.small = small;
    }

    @XmlIDREF
    public Big getBig() {
        return big;
    }

    public void setBig(Big big) {
        this.big = big;
    }

    @XmlElementWrapper(name = "smalls")
    @XmlElement(name = "small")
    public List<Small> getSmalls() {
        return smalls;
    }

    public void setSmalls(List<Small> smalls) {
        this.smalls = smalls;
    }
}

I am using the following test code:

public class Test2 {
    public static void main(String[] args) throws Exception {
        Small s1 = new Small();
        Small s2 = new Small();
        Big b1 = new Big();

        List<Small> smalls = new LinkedList<Small>();
        smalls.add(s1);
        smalls.add(s2);
        smalls.add(b1);

        Baz baz = new Baz();
        baz.setSmalls(smalls);
        baz.setSmall(s2);
        baz.setBig(b1);

        JAXBContext jc = JAXBContext.newInstance(Baz.class);
        Marshaller m = jc.createMarshaller();
        m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        m.marshal(baz, System.out);
    }
}

Unfortunately when doing the marshal, I am faced with the following exception:

Exception in thread "main" javax.xml.bind.JAXBException: 
Exception Description: Invalid XmlIDREF on property [big].  Class [test.moxy.Big] is required to have a property annotated with XmlID.

I would expect that the XmlID annotation would be inherited by the Big class. I have tried adding “another” @XmlID annotation in the Big class, which fixes the marshal problem. This however leads to another problem when generating a XML Schema, which will now contain two ID attributes, which is not allowed.

Am I doing something wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T11:06:00+00:00Added an answer on May 24, 2026 at 11:06 am

    The behaviour you are seeing is a bug (https://bugs.eclipse.org/353787). We have checked in a fix to the EclipseLink 2.3.1 and 2.4.0 streams which will be available from our nightly download page starting August 4th, 2011:

    • http://www.eclipse.org/eclipselink/downloads/nightly.php
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having the following class: public class SomeClass { private readonly int[] _someThings; public SomeClass()
Having the following classes, in two different assemblies: class Member { public string Label
Having the following class (.Net 3.5): public class Something { public string Text {get;
Having the following classes (highly simplified): public class Child { public string Label; public
I am having following function public static Date parseDate(String date, String format) throws ParseException
I have the following class hierarchy [BsonKnownTypes(typeof(MoveCommand))] public abstract class Command : ICommand {
I am having following action link: <%= Html.ActionLink(Check this, Edit, test, new { id
I am very new to asp and having following problem I am getting 2
Suppose I have the following class hierarchy: class A { int foo; virtual ~A()
I am having following condition: @interface MyClass:NSObject @public NSString *str; @end @implementation -(id)init{ }

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.