从命名空间读取 XML 时编组链接异常

Marshalling linking exception when reading XML from namespace

我正在尝试整理对象并将其发送到 JMS。
我做错了什么?

QName qName = new QName("http://schema.gspt.net/EventCanonical/1.0","OrderType");
JAXBElement<OrderType> jaxbElement = new JAXBElement( qName, OrderType.class,orderType);
jaxb2Marshaller.createMarshaller().marshal(jaxbElement,sw);

javax.xml.bind.MarshalException
- with linked exception:
[com.sun.istack.internal.SAXException2: com.radial.notification.event.OrderType is not known to this 
context

这是 XML

中的命名空间
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="http://schema.gspt.net/EventCanonical/1.0" 
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://schema.gspt.net/EventCanonical/1.0" elementFormDefault="qualified" 
attributeFormDefault="unqualified">

实际工作的经典方法

JAXBContext jaxbContext = JAXBContext.newInstance(OrderType.class);
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.marshal(orderType, sw);

将 类 设置为绑定解决了问题

Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setClassesToBeBound(OrderType.class)