Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JAXB doesnt create the XsdSchemaCollection bean using DefaultWsdl11Definition correctly [SWS-1041] #1108

gregturn opened this issue Oct 6, 2018 · 0 comments


Copy link

@gregturn gregturn commented Oct 6, 2018

Nikolas Charalambidis opened SWS-1041 and commented


I have two schemas in src/main/resources with the same namespace www.mycompany.comschemaA.xsd and schemaB.xsd have the same header:

<xs:schema xmlns:xs=""

My WebServiceConfiguration`` extending ``WsConfigurerAdapter`` defines aside the ``ServletRegistrationBean`` also the following ``XsdSchema(Collection)`` beans:

// Just a bean with one schema
public XsdSchema schema() {
    return new SimpleXsdSchema(new ClassPathResource("xsd/schemaA.xsd"));

// A bean with both schemas
public XsdSchemaCollection schemaCollection() {
    return new XsdSchemaCollection() {

        public XsdSchema[] getXsdSchemas() {
            return new XsdSchema[] {
                new SimpleXsdSchema(new ClassPathResource("xsd/schemaA.xsd")),
                new SimpleXsdSchema(new ClassPathResource("xsd/schemaB.xsd"))

        public XmlValidator createValidator() {
            throw new UnsupportedOperationException();

And the WSDL bean:

@Bean(name = "soapWsdl")
public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema schema, XsdSchemaCollection schemaCollection) {
    DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition(); 
    // At this point I use just one of the folliwing:
    return wsdl11Definitionl;

Using one of these in the bean above:

  • wsdl11Definition.setSchema(schema);

If I use only XsdSchema defining one schema (regardless whether schemaA or schemaB), everything works, the SOAP Web service is running and WSDL is generated

  • wsdl11Definition.setSchemaCollection(schemaCollection);

Now the NPE is thrown although the InliningXsdSchemaTypesProvider sets the one schema as the collection with one schema. The error thrown is:

2018-10-05 21:29:28.636 WARN 164968 — [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'soapWsdl' defined in class path resource [cz/vse/soap/WebServiceConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate []: Factory method 'defaultWsdl11Definition' threw exception; nested exception is java.lang.NullPointerException


Caused by: java.lang.NullPointerException: null at org.springframework.xml.xsd.SimpleXsdSchema.getTargetNamespace( ~[spring-xml-3.0.3.RELEASE.jar!/:na] at com.mycompany.WebServiceConfig.defaultWsdl11Definition( ~[classes!/:0.0.1]

I make the things work with calling the SimpleXsdSchema::afterPropertiesSet which is not somehow called upon the bean instantiation. Hard to say what happens. However, editing the method like this makes the schemas work together:

public XsdSchema[] getXsdSchemas() {
    SimpleXsdSchema[] schemaArray = new SimpleXsdSchema[] {
        new SimpleXsdSchema(new ClassPathResource("xsd/schemaA.xsd")),
        new SimpleXsdSchema(new ClassPathResource("xsd/schemaB.xsd"))
    for (SimpleXsdSchema schema : schemaArray) {
        try { 
        } catch (ParserConfigurationException | IOException | SAXException e) { 
            /* ...*/

    return schemaArray;

Why passing the XsdSchema and XsdSchemaCollection doesn't behave equally even they are supposed to do according to DefaultWsdl11Definition? I expect it should work even without calling the schema.afterPropertiesSet().

Affects: 2.0.5

Reference URL:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

1 participant