You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by amichalec <an...@gmail.com> on 2009/02/20 17:58:45 UTC

JAXB ingores @XmlElement(required=true) on unmarshalling in JAX-RS

I know this problem is specific to JAXB but I wonder if it's either known
issue or I have wrong setup. I am trying to force check on required XML
elements in JAX-RS request using CXF2.2/JAXB2.1. I can still successfully
pass thru XML doc with missing elements leading to backend logic failing
with NPEs etc. 
I've found one suggestion on specifying JAXB jars before CXF jar on
classpath but it's hard to do with webapp classloader.
Any ideas?

cheers,
andy.
-- 
View this message in context: http://www.nabble.com/JAXB-ingores-%40XmlElement%28required%3Dtrue%29-on-unmarshalling-in-JAX-RS-tp22122276p22122276.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: JAXB ingores @XmlElement(required=true) on unmarshalling in JAX-RS

Posted by Sergey Beryozkin <sb...@progress.com>.
Hi,

May be JAXBElementProvider needs few tweaks (in the AbstractJAXBProvider) ? Schema validation is supported there, see for ex [1].

But I believe you're talking about different type of validation. May be a proper Validator can be created if it's required through 
the configuration. For ex, we can add a property which will enable the validation in general, and if no schemas have been set then a 
default JAXB validator will be created

Cheers, Sergey

[1] http://svn.apache.org/repos/asf/cxf/trunk/systests/src/test/resources/jaxrs/WEB-INF/beans.xml

>
> I know this problem is specific to JAXB but I wonder if it's either known
> issue or I have wrong setup. I am trying to force check on required XML
> elements in JAX-RS request using CXF2.2/JAXB2.1. I can still successfully
> pass thru XML doc with missing elements leading to backend logic failing
> with NPEs etc.
> I've found one suggestion on specifying JAXB jars before CXF jar on
> classpath but it's hard to do with webapp classloader.
> Any ideas?
>
> cheers,
> andy.
> -- 
> View this message in context: 
> http://www.nabble.com/JAXB-ingores-%40XmlElement%28required%3Dtrue%29-on-unmarshalling-in-JAX-RS-tp22122276p22122276.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>