File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes getting ValidationException--Need help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "getting ValidationException--Need help" Watch "getting ValidationException--Need help" New topic
Author

getting ValidationException--Need help

naveen sakhare
Greenhorn

Joined: Dec 16, 2013
Posts: 17
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

Joined: Mar 22, 2000
Posts: 12769
    
    5
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

Joined: Dec 16, 2013
Posts: 17
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

Joined: Jan 18, 2011
Posts: 511
    
    3
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

Joined: Dec 16, 2013
Posts: 17
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

Joined: Mar 22, 2000
Posts: 12769
    
    5
.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


 
wood burning stoves
 
subject: getting ValidationException--Need help