JAX-WS MarshalException with custom JAX-B bindings: Unable to marshal type “java.lang.String” as an element because it is missing an @XmlRootElement annotation?

You need to add a xjc:simple element inside your jaxb:globalBindings section for making JAXB handling root elements correctly. Just insert the following into your bindings file.

You need to add a element inside your section for making JAXB handling root elements correctly. Just insert the following into your bindings file I have a JAXB mapping sample here you can use for inspiration.

Thanks for posting the sample Lars. I've been struggling with using the xjc:simple tag in a bindings file that includes both of the following: Basically the 'catalog' element contains a sequence of various kinds of different complexType elements with different tag names and when xjc auto-creates the classes without the binding to rename the sequence it produces something like 'itemType1AndItemType2' etc for the list and the methods involving it. I want to change that list to something better like just "catalogItems".

If I comment out the xjc:simple part it works or if I comment out the sequence rename binding everything also works, but they both won't work together. Any ideas why this would be? The error I'm getting is: ERROR compiler was unable to honor this property customization.It is attached to a wrong place, or its inconsistent with other bindings.

That error means JAXB is trying to marshall a String as if it were an XML element -- which it obviously isn't. So, for example marshalling "foo" as XML, when really it should be something like "foo". The reason it's doing this is because of the mapping... making an element to a String also has the same effect the other way: so it's trying to map the String to an element, which results in invalid XML.

Lars' solution with should work. The other thing you can do is map it to a (simple) custom class that JAXB can marshal. If you're brave, you can try messing around with JAXBElement too.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions