• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

JAXB Exception

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
im using jaxb to manipulate xml document.i created the schema classes from the xsd document.Im tring to run a program that's displaying the values in a xml document .my code goes like this:


public static void main(String srgs[]){
try{
JAXBContext jContext = JAXBContext.newInstance("generated");
Unmarshaller unmarshaller = jContext.createUnmarshaller();
//unmarshaller.setValidating(true); //LINE 1
PurchaseOrder purchaseorder = (PurchaseOrder)unmarshaller.unmarshal(new File("PurchaseOrder.xml"));
BillToType billto = purchaseorder.getBillTo();
System.out.println("Name:"+billto.getName());
System.out.println("Street:"+billto.getStreet());
System.out.println("City:"+billto.getCity());
System.out.println("State:"+billto.getState());
ItemsType items = purchaseorder.getItems();
List itemsList=items.getItem();
for(int i=0;i<itemsList.size();i++){
Item item=(Item)itemsList.get(i);
System.out.println("productName:"+item.getProductName());
System.out.println("Quantity:"+item.getQuantity());
System.out.println("Price:"+item.getPrice());
}
}

when my line 1 is commented im getting a perfect result.but when i include the line 1 im getting "JAXBException:unable to extract the schema information".can anyone pls tell me how to overcome this problem?
 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you say:

JAXBContext jContext = JAXBContext.newInstance("generated");

Are your JAXB-generated classes really in the "generated" folder? Are you sure they aren't in the current folder or some other folder? Should your code say soemthing like this instead?:

JAXBContext jContext = JAXBContext.newInstance("javaranch.generated");
 
Eshu San
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually my compiler generated schema classes are in the directory called "generated" .so i think that part of the program is correct.pls guide me if im wrong..

Thanks
 
It is no measure of health to be well adjusted to a profoundly sick society. -Krishnamurti Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic