Meaningless Drivel is fun!
The moose likes EJB and other Java EE Technologies and the fly likes Getting Error while preparing XML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Getting Error while preparing XML" Watch "Getting Error while preparing XML" New topic

Getting Error while preparing XML

Preetish Madalia
Ranch Hand

Joined: Dec 12, 2007
Posts: 37
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
mentDataPBV nor any of its super class is known to this context.
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextI
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.
at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(
at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.ja

Following is my XML generation code :

public static String prepareXML(Object obj) {
JAXBContext jc;
ByteArrayOutputStream stream = null;
try {
System.out.println("String1 :" + JAXBContext
jc = JAXBContext

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) {
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.
I agree. Here's the link:
subject: Getting Error while preparing XML
jQuery in Action, 3rd edition