Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JAXB Exception: Class not known to this context while marshalling

I am getting below error while marshalling. I generated xml's from schemas.

[javax.xml.bind.MarshalException
- with linked exception:
[com.sun.istack.internal.SAXException2: class org.com.AccountsComplexType nor any of its super class is known to this context.

After a little research, some people says "Try adding @XmlSeeAlso(...class)" but the problem is AccountsComplexType class is not a XmlRootElement.

Is there any idea what am I doing wrong?

like image 224
hellzone Avatar asked Nov 12 '22 19:11

hellzone


1 Answers

If you generated the classes form an XML schema then you should bootstrap the JAXBContext from the package name of the generated model or the ObjectFactory class.

like image 133
bdoughan Avatar answered Nov 15 '22 02:11

bdoughan