cdiweldweld-secdi-2.0

Warning at Weld 3 startup with XSD invalid beans.xml for weld:scan tag


I just updated Weld from version 2.4.4 to 3.0.1. I am facing the following error at the application startup and I cannot found a solution. I am using Weld SE.

Sep 15, 2017 1:25:12 PM org.jboss.weld.xml.BeansXmlHandler error
WARN: WELD-001208: Error when validating file:/(...)/META-INF/beans.xml@7 against xsd. cvc-complex-type.2.4.a: Invalid content was found starting with element 'weld:scan'. One of '{"http://xmlns.jcp.org/xml/ns/javaee":interceptors, "http://xmlns.jcp.org/xml/ns/javaee":decorators, "http://xmlns.jcp.org/xml/ns/javaee":alternatives, "http://xmlns.jcp.org/xml/ns/javaee":scan, "http://xmlns.jcp.org/xml/ns/javaee":trim}' is expected.

The beans.xml contains a Weld specific tag to include some classes in the scan (as only exclusion is supported by the CDI specification).

<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:weld="http://jboss.org/schema/weld/beans"
       xmlns="http://xmlns.jcp.org/xml/ns/javaee"
       xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
        http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
       bean-discovery-mode="all">
    <weld:scan>
        <weld:include name="com.company.mypackage"/>
        (...)
    </weld:scan>
</beans>

I use the following Maven Weld SE dependency.

<dependency>
    <groupId>org.jboss.weld.se</groupId>
    <artifactId>weld-se-core</artifactId>
    <version>3.0.1.Final</version>
</dependency>

Could you tell me what should I do to solve this problem? I have checked for a CDI 2.0 XSD but I haven't found any. Perhaps, the include restriction for the scan is now supported natively by CDI? Or perhaps the Weld XSD has changed?

I have created a ticket on the bug tracker of Weld in case it is a bug.


Solution

  • Found the problem - I tried to describe in in JIRA issue for CDI (CDI-717).

    But to sum it up here, it's not Weld issue, but rather a problem with CDI 2.0 XSD validation file. There was a unintended change where one line was removed. This line permitted any implementation (e.g. Weld) to add additional elements (from different namespaces) and still pass the XSD validation.

    Just for completness, the former XSD file can be seen here (with the link to missing line). The new one is then here.

    BTW you are safe to run your application even with these validation warnings/error. Weld notices them, but should be able to deal with them and still run your app.