|
16 | 16 | import java.util.Set; |
17 | 17 | import java.util.StringTokenizer; |
18 | 18 |
|
| 19 | +import jakarta.validation.NoProviderFoundException; |
19 | 20 | import jakarta.validation.constraints.Digits; |
20 | 21 | import jakarta.validation.constraints.Max; |
21 | 22 | import jakarta.validation.constraints.Min; |
@@ -97,14 +98,24 @@ public static void activate(ActivationContext context) { |
97 | 98 | catch (IntegrationException e) { |
98 | 99 | final Set<ValidationMode> validationModes = context.getValidationModes(); |
99 | 100 | if ( validationModes.contains( ValidationMode.CALLBACK ) ) { |
100 | | - throw new IntegrationException( "Bean Validation provider was not available, but 'callback' validation was requested", e ); |
| 101 | + throw new IntegrationException( "Jakarta Validation provider was not available, but 'callback' validation mode was requested", e ); |
101 | 102 | } |
102 | 103 | else if ( validationModes.contains( ValidationMode.DDL ) ) { |
103 | | - throw new IntegrationException( "Bean Validation provider was not available, but 'ddl' validation was requested", e ); |
| 104 | + throw new IntegrationException( "Jakarta Validation provider was not available, but 'ddl' validation mode was requested", e ); |
104 | 105 | } |
105 | 106 | else { |
106 | | - LOG.debug( "Unable to acquire Bean Validation ValidatorFactory, skipping activation" ); |
107 | | - return; |
| 107 | + if ( e.getCause() != null && e.getCause() instanceof NoProviderFoundException ) { |
| 108 | + // all good, we are looking at the ValidationMode.AUTO, and there are no providers available. |
| 109 | + // Hence, we just don't enable the Jakarta Validation integration: |
| 110 | + LOG.debug( "Unable to acquire Jakarta Validation ValidatorFactory, skipping activation" ); |
| 111 | + return; |
| 112 | + } |
| 113 | + else { |
| 114 | + // There is a Jakarta Validation provider, but it failed to bootstrap the factory for some reason, |
| 115 | + // we should fail and let the user deal with it: |
| 116 | + throw e; |
| 117 | + |
| 118 | + } |
108 | 119 | } |
109 | 120 | } |
110 | 121 |
|
|
0 commit comments