• 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 Error while preparing XML

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I m trying to create an XML request object using JAXB api. Upon calling marshall() function I m getting following exception :

javax.xml.bind.JAXBException: class com.b2b.network.wsi.shipment.creditcard.Shi
mentDataPBV nor any of its super class is known to this context.
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextI
pl.java:507)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.
ava:449)
at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java
292)
at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.ja
a:221)

Following is my XML generation code :

public static String prepareXML(Object obj) {
JAXBContext jc;
ByteArrayOutputStream stream = null;
try {
System.out.println("String1 :" + JAXBContext
.newInstance("com.b2b.network.wsi.shipment.creditcard"));
jc = JAXBContext
.newInstance("com.b2b.network.wsi.shipment.creditcard");

System.out.println("String2 :");
Marshaller marshaller = jc.createMarshaller();
System.out.println("String3 :");
stream = new ByteArrayOutputStream();
System.out.println("Strin4 :");
marshaller.marshal(obj, stream);


System.out.println("String :" + stream.toString());
} catch (JAXBException e) {
e.printStackTrace();
}
return stream.toString();
}

Here, only the ObjectFactory class is getting added to JAXBContext, while the other classes are not added. Can you please give my any suggestion on this. thanks in adv.
 
Stinging nettles are edible. But I really want to see you try to eat this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic