Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JAXB does not generate @XmlRootElement

 
Anish Shah
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why does JAXB put @XmlRootElement sometimes but not always?

The above link is preety much where i am stuck.. It does not generate @XmlRootElement.. I also tried using their solution of :

jaxb-xjc version : jaxb-xjc-2.1.10.jar.. so i have changed my jaxb:version to 2.1 from 1.0 above...

Generated Code from above XSD



I just can't get it to generate @XmlRootElement over my class...something like below


(P.S.) I need it for my web services implementation...

Thanks you very much...
 
Kris Schneider
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This probably belongs in the "Web Services" forum...

You haven't actually defined any elements in your schema, just a type. Obviously, you have to decide what makes the most sense in terms of your schema design, but what if you change it to something like:



Read the java.net blog entry a bit more carefully and you'll see that it's really addressing elements and not types...which makes sense given the name of the annotation: XmlRootElement
 
Rob Spoor
Sheriff
Pie
Posts: 20532
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kris Schneider wrote:This probably belongs in the "Web Services" forum...

So that's where this thread is going.
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
Take a look at this web page: http://weblogs.java.net/blog/2006/03/03/why-does-jaxb-put-xmlrootelement-sometimes-not-always
It should answer your question.
Best wishes!
 
Kris Schneider
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ivan Krizsan wrote:Take a look at this web page...


Which is the exact same page referenced in the original post...on the first line.

Ivan Krizsan wrote:It should answer your question.


If hindsight is any guide, I'm guessing not.
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kris Schneider wrote:
Which is the exact same page referenced in the original post...on the first line.

Sorry, I did not see the link, my fault.
 
Anish Shah
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kris.. you were so right.. its about the Element as you said.. I had to change my design around but it worked.. Thank you very much for your advice..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic