Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting ValidationException--Need help

 
naveen sakhare
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I dont know whether I am posting this issue in correct page.But I need help on this one.

I am getting javax.xml.bind.ValidationException: the object parameter to validate() or validateRoot() is not validatable while validating the object.After validating I need to do marshalling for this.

Marshaller marshaller = jaxbContext.newInstance("class name/jar name");
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.setProperty(Marshaller.JAXB_ENCODING, ENCODING);
if (true) {
Validator v = jaxbContext.createValidator();
v.validate(order);
}
marshaller.marshal(order, outputStream);


Kindly help as I am struck on this one.
Thank you.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That error message says that this code:



is not passing the validate method something that can be validated - unfortunately your post does not say what "order" is - please explain

Bill
 
naveen sakhare
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
William Brogden wrote:That error message says that this code:



is not passing the validate method something that can be validated - unfortunately your post does not say what "order" is - please explain

Bill


Order is a JAXB object.Here after creating the JAXB object I am trying to do Marshalling.Before marshalling I am calling validate() method and it is failing.If you want code I can post it.I want to know what this error means??
 
g tsuji
Ranch Hand
Posts: 666
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you conciously using jaxb 1.0 in favor of jaxb 2.0 ? Validation has changed much and jaxb 1.0 Validator interface has practically all deprecated and is not necessarily supported anymore. But who else is to stop you from using jaxb 1.0 if you want to !
 
naveen sakhare
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unfortunately I am using jaxb 1.0.I can't use 2.0 as my project is already using 1.0 in a lot of places. Any suggestions??
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
.I want to know what this error means??


It means exactly what it says of course. Something about the "order" object makes it impossible to validate.

Browsing the JavaDocs, it looks like you could register a custom ValidationEventHander and examine the problem more closely via a ValidationEventLocator.

Bill


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic