• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

getting ValidationException--Need help

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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??
 
Ranch Hand
Posts: 734
7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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


 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic