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

  • SEARCH
  • Home
  • 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 6866149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:08:38+00:00 2026-05-27T03:08:38+00:00

I am new to java (coming from c#.net background) and was trying the above

  • 0

I am new to java (coming from c#.net background) and was trying the above example to marshal and unmarshal.

Following the link below
Marshalling a List of objects implementing a common interface, with JaxB

using the above technique as mentioned by Mr.Blaise Doughan, I was able to marshal the java objects to xml. But when i save this xml and try to unmarshal the xml back to java object i get the following on the console:

com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 2
counts of IllegalAnnotationExceptions
@javax.xml.bind.annotation.XmlElementRef annotation is found on two
places; one would be suffice. this problem is related to the following
location: at @javax.xml.bind.annotation.XmlElementRef(name=##default,
required=true, type=class
javax.xml.bind.annotation.XmlElementRef$DEFAULT, namespace=) at public
java.util.List Community.getPeople() at Community this problem is
related to the following location: at
@javax.xml.bind.annotation.XmlElementRef(name=##default,
required=true, type=class
javax.xml.bind.annotation.XmlElementRef$DEFAULT, namespace=) at public
void Community.setPeople(java.util.List) at Community ….

Note : I have created getters/setters for Class Boy and Class Girl for implementing unmarshalling.

  • 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-27T03:08:39+00:00Added an answer on May 27, 2026 at 3:08 am

    It appears that you may have annotated both the getPeople and setPeople methods. JAXB (and other Java EE technologies) only require you annotate one.

    public class Community {
    
        private List<Person> people;
    
        @XmlElementRef
        public List<Person> getPeople() {
            return people;
        }
    
        public void setPeople(List<Person> people) {
            this.people = people;
        } 
    
    }
    

    For More Information

    • http://blog.bdoughan.com/2010/11/jaxb-and-inheritance-using-substitution.html
    • http://blog.bdoughan.com/2011/06/using-jaxbs-xmlaccessortype-to.html
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im new to VB. I am coming from a Java background. In the following
I am new to C# and .Net and am coming from a Java background.
I'm very new to Python (I'm coming from a JAVA background) and I'm wondering
I am new to Java coming from a PHP background so sorry if this
First off my background: I'm new to Java coming over from Ruby. If that
I am new to C++ coding, coming from Java and C# background. I'm puzzled
I am learning Scala (coming from a background of mostly Java). I am trying
Coming from a Java background it is new for me to deal with the
I'm new to Ruby coming from Java. I'm trying to make a http get
I am new to the world of Java. I'm coming from C#. I'm trying

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.