springspring-bootwildflybean-validation

WELD-001408: Unsatisfied dependencies for type Validator with qualifiers @Default With Spring Boot 3.1.1 and Jboss Wildfly 27


In an application with Spirng boot and Jboss Wildfly i take this error when i migarte the app to Spring boot 3.1.1 and wildfly 27 :

Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type Validator with qualifiers @Default
  at injection point [UnbackedAnnotatedField] @Inject private org.hibernate.validator.cdi.internal.interceptor.ValidationInterceptor.validator
  at org.hibernate.validator.cdi.internal.interceptor.ValidationInterceptor.validator(ValidationInterceptor.java:0)
WELD-001475: The following beans match by type, but none have matching qualifiers:
  - ValidatorBean [id=org.hibernate.validator.cdi.internal.ValidatorBean_hv, qualifiers=[@org.hibernate.validator.cdi.HibernateValidator(), @jakarta.enterprise.inject.Any()]]
"}}

this app work fine with Spring boot 2.7 and Jboss WildFly 15 .

for more information that can help , I deploy war file of the app to Wildfly and excluding embeded containers and import jakarta.servlet-api when i try to build the app :

<dependency>
    <groupId>jakarta.servlet</groupId>
    <artifactId>jakarta.servlet-api</artifactId>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <exclusions>
        <exclusion>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </exclusion>
    </exclusions>
</dependency>

and this app work fine with embeded containers.


Solution

  • after some search and review on Wildfly i understand we need to use a jboss-deployment-structure.xml to exclude bean-validation subsystem. i'm alo exclude jsf and weld as well. this is jboss-deployment-structure.xml that solve the prblem :

    <?xml version="1.0"?>
    <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <deployment>
            <!-- Spring does not support CDI and therefore CDI required subsystem and dependencies must be excluded -->
            <exclude-subsystems>
                <subsystem name="jsf"/>
                <subsystem name="microprofile-opentracing-smallrye"/>
                <subsystem name="weld"/>
                <subsystem name="logging"/>
            </exclude-subsystems>
            <exclusions>
                <module name="org.jboss.resteasy.resteasy-cdi"/>
            </exclusions>
        </deployment>
    </jboss-deployment-structure>