I've experimented a bit locally, setting the schema location property without registering the providers explicitly works for me.

I'm not sure why you had no validation errors reported after you saw the WARNING messages (related to loading the schema resources) gone.

Can you remove the provider registration block from beans.xml and put few breakpoints in a (default) JAXBElementProvider in methods where Schema is used ? The fact the WARNING messages have gone clearly indicates that a schema resource has been loaded - it is difficult to figure out why the actual validation does not work afterwards (unless the JAXB provider is explicitly registered).

So either debug (simply download a CXF source) and let me know what you've found or create a test case and I'll investigate further
Sergey

On 08/12/14 14:48, Sergey Beryozkin wrote:
I'll have a look why it does not work without a registered provider,
might be a regression (FYI, the same would work by just registering a
CXF JAXB providder without extending it - tat was only needed to confirm
a custom Schema is available).

Not 100% sure about the actual validation issue (it is not a CXF issue)
in this specific case it appears to be the XML instance is not qualified
with a namespace

Cheers, Sergey
On 08/12/14 14:30, nikosdim wrote:
Hi

Here is the update

I registered the provider
<bean id="jaxbElementProvider"
class="com.ba.sysman.providers.MyJAXBElementProvider"></bean>

and now it goes through validation of the xsd. Without the provider it
doesn't and I have not put any logic in the privider. Just overrided
getSchema(Class<?> cls) and put a breakpoint to see if it is called.
Is this a bug with the spring configuration of cxf ?


After having registered the provider I send a request to the service
with an
xml but I get this

*JAXBException occurred : cvc-elt.1: Cannot find the declaration of
element
'incident'.. cvc-elt.1: Cannot find the declaration of element
'incident'..
*



*My xml:*

<incident>
    <eventTitle>Test Title from wrapper</eventTitle>
    <eventDescription>Test description from BAwrapper</eventDescription>
    <affectedUserName>U88sdfs888</affectedUserName>
         <affectedUserTelephone>+440-98772345nj</affectedUserTelephone>
    <reportingUserName>U88888</reportingUserName>
    <eventCategoryName>INCIDENT</eventCategoryName>
    <eventSeriousness>4</eventSeriousness>
    <serviceDepartmentName>NETTECHS</serviceDepartmentName>
    <affectedServiceName>ASSYST</affectedServiceName>
    <affectedAssetName>LXVIRT910</affectedAssetName>
</incident>


*My xsd:*
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
    xmlns="http://www.mydomain.com/schema/Wrapper/incident";
    xmlns:xsd="http://www.w3.org/2001/XMLSchema";
    targetNamespace="http://www.mydomain.com/schema/Wrapper/incident";
    elementFormDefault="qualified">

    <xsd:element name="incident">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="eventTitle">
                    <xsd:simpleType>
                        <xsd:restriction base="xsd:string">
                            <xsd:minLength value="1"></xsd:minLength>
                            <xsd:maxLength value="254"></xsd:maxLength>
                        </xsd:restriction>
                    </xsd:simpleType>
                </xsd:element>
                <xsd:element name="eventDescription">
                    <xsd:simpleType>
                        <xsd:restriction base="xsd:string">
                            <xsd:minLength value="1"></xsd:minLength>
                            <xsd:maxLength value="890"></xsd:maxLength>
                        </xsd:restriction>
                    </xsd:simpleType>
                </xsd:element>
                <xsd:element name="affectedUserName">
                    <xsd:simpleType>
                        <xsd:restriction base="xsd:string">
                            <xsd:maxLength value="254"></xsd:maxLength>
                        </xsd:restriction>
                    </xsd:simpleType>s
                </xsd:element>
                <xsd:element
                    name="affectedUserTelephone"
                    minOccurs="0">
                    <xsd:simpleType>
                        <xsd:restriction base="xsd:string">s
                            <xsd:maxLength value="30"></xsd:maxLength>
                        </xsd:restriction>
                    </xsd:simpleType>
                </xsd:element>
                <xsd:element
                    name="reportingUserName"
                    minOccurs="0">
                    <xsd:simpleType>
                        <xsd:restriction base="xsd:string">
                            <xsd:maxLength value="254"></xsd:maxLength>
                        </xsd:restriction>
                    </xsd:simpleType>
                </xsd:element>
                <xsd:element name="eventCategoryName">
                    <xsd:simpleType>
                        <xsd:restriction base="xsd:string">
                            <xsd:maxLength value="254"></xsd:maxLength>
                        </xsd:restriction>
                    </xsd:simpleType>
                </xsd:element>
                <xsd:element name="eventSeriousness">
                    <xsd:simpleType>
                        <xsd:union memberTypes="empty">
                            <xsd:simpleType>
                                <xsd:restriction base="xsd:integer">
                                    <xsd:pattern
value="[1|2|3|4]"></xsd:pattern>
                                </xsd:restriction>
                            </xsd:simpleType>
                        </xsd:union>
                    </xsd:simpleType>
                </xsd:element>
                <xsd:element name="serviceDepartmentName">
                    <xsd:simpleType>
                        <xsd:restriction base="xsd:string">
                            <xsd:maxLength value="15"></xsd:maxLength>
                        </xsd:restriction>
                    </xsd:simpleType>
                </xsd:element>
                <xsd:element name="affectedServiceName">
                    <xsd:simpleType>
                        <xsd:restriction base="xsd:string">
                            <xsd:maxLength value="254"></xsd:maxLength>
                        </xsd:restriction>
                    </xsd:simpleType>
                </xsd:element>
                <xsd:element name="affectedAssetName">
                    <xsd:simpleType>
                        <xsd:restriction base="xsd:string">
                            <xsd:maxLength value="254"></xsd:maxLength>
                        </xsd:restriction>
                    </xsd:simpleType>
                </xsd:element>
                <xsd:element
                    name="attachments"
                    minOccurs="0">
                    <xsd:complexType>
                        <xsd:sequence maxOccurs="10">
                            <xsd:element name="attachment">
                                <xsd:complexType>
                                    <xsd:sequence>
                                        <xsd:element
                                            name="name"

type="xsd:string"></xsd:element>
                                        <xsd:element
                                            name="description"

type="xsd:string"></xsd:element>
                                        <xsd:element
                                            name="fileName"

type="xsd:string"></xsd:element>
                                        <xsd:element
                                            name="fileExtension"
                                            type="xsd:string"
                                            default="txt"></xsd:element>
                                        <xsd:element
                                            name="binary"

type="xsd:base64Binary"></xsd:element>
                                    </xsd:sequence>
                                </xsd:complexType>
                            </xsd:element>
                        </xsd:sequence>
                    </xsd:complexType>
                </xsd:element>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    <xsd:simpleType name="empty">
        <xsd:restriction base="xsd:string">
            <xsd:length value="0"></xsd:length>
        </xsd:restriction>
    </xsd:simpleType>
</xsd:schema>




--
View this message in context:
http://cxf.547215.n5.nabble.com/Validate-JAXB-Object-with-xsd-schema-tp5751783p5752054.html

Sent from the cxf-user mailing list archive at Nabble.com.




Reply via email to