Skip to main content

and nillable elements

Please note these forums are being decommissioned and use the new and improved forums at
1 reply [Last post]
Joined: 2012-08-23

We have an existing application we are migrating from JAX-RPC with XmlBeans to JAX-WS with JAXB with CXF

Some of the elements are defined with minOccurs as well as nillable ="true", for example

We are using bindings. However the isNil and setNil are available only in JAXBElement object. Hence when we deploy the web service we are not able to distinguish between

versus the node missing scenario

We tried other options to override the bindings like this

Though the proerty type, gettter/setter are getting generated properly like below

JAXB class

@XmlElement(name = "Description", namespace = "namespace", type = java.lang.String.class, nillable = true)
protected JAXBElement description;


@XmlElementDecl(namespace = "namespace", name = "Description")
public JAXBElement createDescription(String value) {
return new JAXBElement(_Description_QNAME, String.class, null, value);
The CXF is erroring out when input is sent as

The error is

env:Serverjava.lang.String cannot be cast to javax.xml.bind.JAXBElementnamespace$JaxbAccessorF_description!set!!56

Is there a good way to handle this. Changing the schema is not an option due to backward compatibility issues with the clients

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2005-01-14

CXF is a competitor project--it would probably be best to ask your question on the CXF user's mailing list. For information on modifying the JAXB-generated artifacts during the wsdl-to-Java process, this article might help: