Home > JAXB > The attribute required is undefined for the annotation type XmlElementRef

The attribute required is undefined for the annotation type XmlElementRef

Here is the solution

This is an error due to JAXB. More specifically, this is due to the fact that 2 versions of JAXB are being used.

JDK 1.6 now comes with JAXB, but a slightly older version (2.1.1 I believe) which leads to the following error message in your favorite IDE:

The attribute required is undefined for the annotation type XmlElementRef

The only way to solve it was to change the order of my build class path in Eclipse 

Ref: http://www.coderanch.com/t/532592/Web-Services/java/attribute-required-undefined-annotation-type

About these ads
Categories: JAXB
  1. Matteo T,
    September 27, 2011 at 3:46 pm | #1

    I solved copying jaxb-api.jar into %JAVA_HOME%/jre/lib/endorsed and using ant to compile (javac).

    But I have the same problem in Eclipse IDE. Is there a option to let Eclipse compiler to use jaxb 2.2?

    • April 16, 2013 at 7:26 am | #2

      To resolve this in Eclipse: Right Click on the project -> Properties -> Java Build Path -> Oder and Export -> Check ‘JRE System Lib’ -> Down: till it goes to the bottom. That should resolve your problem.

  2. June 14, 2012 at 8:29 pm | #3

    Changing the build order did the trick for me.
    Thanks for sharing your knowledge!

  3. September 21, 2012 at 8:30 am | #4

    Changing the build order worked for me too, thanks :-)

  4. Ralph
    October 11, 2012 at 1:52 pm | #5

    Eclipse did show me that error too and after moving the apache-cxf libraries over the jre6 the problem disapeared.

    Thanks for that info! Its just priceless!

  5. G
    March 6, 2013 at 4:08 pm | #6

    I’ve moved the JRE System Library over the Apache Tomcat v6.0 and it workes fine ;)
    Big Thx from Germany ;)

  6. March 28, 2013 at 6:58 am | #7

    To solve this simply, open .classpath file in your project and make sure following entry should be at top(first of other library files)

    The JRE entry should be at top of all your other Library files.

  7. March 28, 2013 at 7:00 am | #8

    Mohan :
    To solve this simply, open .classpath file in your project and make sure following entry should be at top(first of other library files)
    The JRE entry should be at top of all your other Library files.

  8. AnonymousProgrammer
    July 22, 2013 at 11:19 pm | #9

    I had a similar problem. I have java 7 and 6 both installed on this PC — and my projects are all using 6. java 7 got automatically added to the windows path, replacing 6; so when i executed xjc it compiled according to jaxb 2.2.4 (included in java 7). Changing PATH back to the jre 6, recompiling with xjc, removed the incompatibilities in the IDE (eclipse).

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: