spring-projects / spring-boot

Spring Boot
https://spring.io/projects/spring-boot
Apache License 2.0
75.01k stars 40.66k forks source link

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

Closed mmirzaeyan closed 12 months ago

mmirzaeyan commented 12 months ago

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.

philwebb commented 12 months ago

I'm afraid there isn't enough detail to diagnose if this is a Spring Boot issue, a WildFly issue or a problem with your code. If you'd like us to spend some time investigating, please take the time to provide a complete minimal sample (something that we can unzip or git clone, build, and deploy) that reproduces the problem. Please also provide exact details of how we can deploy the application into WildFly.

mmirzaeyan commented 12 months ago

I'm push a light sample of my application in this repository :

repo I'm build the app as a war file and put in the deplyment directory of Wildfly 27 and start it . I'm not using any Wildfly Maven Plugin .

wilkinsona commented 12 months ago

Thanks for the repo but it isn't quite what we're looking for.

The sample should be minimal. This means that it should not contain any code or dependencies that are not related to the problem. For example, the sample currently seems to require an Oracle database which is unlikely to be related to a problem with Hibernate Validator. Please strip it down to the bare minimum that is required to reproduce the problem.

mmirzaeyan commented 12 months ago

I'm try to do it as simple as I can , I'm remove Oracle database depenecies and push it to the repository .

wilkinsona commented 12 months ago

Unfortunately that hasn't really helped as your application won't start without a database. It also still contains dependencies that are adding complexity yet do not seem to be related to the problem. A notable example of this is camunda-bpm-spring-boot-starter-webapp it has transitive dependencies on spring-boot-starter-tomcat and spring-boot-starter-jersey, both of which clash with Wildfly and its built-in components.

Please minimise the sample as much as possible and verify that it reproduces the problem. We can then take another look.

mmirzaeyan commented 12 months ago

Do we nead beans.xml in Spring boot project when we try deploy it on Wildfly for cdi management ? I'm put a beans.xml file in my WEB-INF directory and put the bean-discovery-mode to all , the exception was changes to :

jakarta.enterprise.inject.UnsatisfiedResolutionException: Unable to resolve a bean for 'org.springframework.data.redis.core.RedisOperations' with qualifiers [@jakarta.enterprise.inject.Default(), @jakarta.enterprise.inject.Any()].

do you have any idea ?

wilkinsona commented 12 months ago

Spring Boot makes no use of CDI so, AFAIK, there should be no need for a beans.xml file. Perhaps Wildfly needs one for some reason but that would be a Wildfly problem and not something that we can help with. FWIW, our deployment test with Wildfly does not have one.

If you'd like us to spend and more time on this, please provide the requested minimal sample otherwise I think it would be best to close this issue as it isn't the right place to find Wildfly expertise and that appears to be what's needed here.

mmirzaeyan commented 12 months ago

Which version of Wildfly can run Spring boot 3 ? Does 27 ok ??

wilkinsona commented 12 months ago

Spring Boot 3 requires Jakarta EE 9. 10 is also supported. Any version of Wildfly that meets those requirements should work. I’m going to close this one now. There’s no evidence of a Spring Boot bug and, as I said above, this isn’t the right place for questions about Wildfly.

mmirzaeyan commented 12 months ago

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.

Thanks for your support @wilkinsona.