2

Got an exception

javax.xml.bind.UnmarshalException: unexpected element 
(uri:"", local:"ConnectorCommandType")

trying to unmarshall xml, shown below:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
  <ConnectorCommandType> ........ </ConnectorCommandType>

The exception basically says that element is not found in jaxb context. But debugging shows that this class is present and known in current jaxb context. The class ConnectorCommandType was generated from xsd xml as <xs:complexType> element.

Could there be an error in the xsd?

Has anyone faced with problem like that? Any suggestions? Thanks.

hcarver
  • 7,126
  • 4
  • 41
  • 67
johnny-b-goode
  • 3,792
  • 12
  • 45
  • 68

1 Answers1

1

The solution depends on the answer to the following question:

Is there an @XmlRootElement(name="ConnectorCommandType") annotation on the ConnectorCommandType class, or an @XmlElementDecl(name="ConnectorCommandType") on a create method in the ObjectFactory class?

If the answer is YES

Is there a package-info in your generated model? It appears as though your JAXB (JSR-222) implementation is expecting a namespace qualified document. Something like:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ConnectorCommandType xmlns="YOUR_NAMESPACE_HERE">
     ........ 
</ConnectorCommandType>

For More Information

If the answer is NO

If the ConnectorCommandType element is not associated with a class, then you will need to use one of the unmarshal methods that takes a class parameter.

bdoughan
  • 147,609
  • 23
  • 300
  • 400
  • 1
    Thak you for help. There was my mistake: in order to use elements as entities during unmarshalling they also should be defined as with related complex type elements. – johnny-b-goode Aug 29 '12 at 09:43