Repository: quarkusio/quarkus
Issue: Hibernate Validator warnings are displayed when optional ResourceBundles are missing

### Describe the bug

When an app depending on the Hibernate Validator extension is package using the native build, the following messages are printed to the output:

``` 
The bundle named: ContributorValidationMessages, has not been found. If the bundle is part of a module, verify the bundle name is a fully qualified class name. Otherwise verify the bundle path is accessible in the classpath.
The bundle named: ValidationMessages, has not been found. If the bundle is part of a module, verify the bundle name is a fully qualified class name. Otherwise verify the bundle path is accessible in the classpath.
The bundle named: messages, has not been found. If the bundle is part of a module, verify the bundle name is a fully qualified class name. Otherwise verify the bundle path is accessible in the classpath.
```

Although that does no harm to the build, it may lead to confusion giving that those bundles are optional.

### Expected behavior

Do not print any message if the bundle does not exist in the user's application

### Actual behavior

The message is printed.

### How to Reproduce?

1. Clone https://github.com/quarkusio/registry.quarkus.io
2. run `mvn clean package -Dnative -DskipTests` 

### Output of `uname -a` or `ver`

Fedora 35

### Output of `java -version`

11

### GraalVM version (if different from Java)

21

### Quarkus version or git rev

2.5.0.Final

### Build tool (ie. output of `mvnw --version` or `gradlew --version`)

Maven 3.8.4

### Additional information

This issue was originated from [a chat in Zulip](https://quarkusio.zulipchat.com/#narrow/stream/187038-dev/topic/Hibernate.20Validation). 

Also it seems that [this snippet](https://github.com/quarkusio/quarkus/blob/main/extensions/hibernate-validator/deployment/src/main/java/io/quarkus/hibernate/validator/deployment/HibernateValidatorProcessor.java#L346-L353) may need to be enhanced to check if the bundle really exists

Changed files:
extensions/resteasy-classic/resteasy-server-common/deployment/src/main/java/io/quarkus/resteasy/server/common/deployment/ResteasyServerCommonProcessor.java
extensions/hibernate-validator/deployment/src/main/java/io/quarkus/hibernate/validator/deployment/HibernateValidatorProcessor.java

diff --git a/extensions/hibernate-validator/deployment/src/main/java/io/quarkus/hibernate/validator/deployment/HibernateValidatorProcessor.java b/extensions/hibernate-validator/deployment/src/main/java/io/quarkus/hibernate/validator/deployment/HibernateValidatorProcessor.java
index 81d69df34b4..428d556583f 100644
--- a/extensions/hibernate-validator/deployment/src/main/java/io/quarkus/hibernate/validator/deployment/HibernateValidatorProcessor.java
+++ b/extensions/hibernate-validator/deployment/src/main/java/io/quarkus/hibernate/validator/deployment/HibernateValidatorProcessor.java
@@ -345,11 +345,28 @@ public void build(HibernateValidatorRecorder recorder, RecorderContext recorderC
 
     @BuildStep
     NativeImageConfigBuildItem nativeImageConfig() {
-        return NativeImageConfigBuildItem.builder()
-                .addResourceBundle(AbstractMessageInterpolator.DEFAULT_VALIDATION_MESSAGES)
-                .addResourceBundle(AbstractMessageInterpolator.USER_VALIDATION_MESSAGES)
-                .addResourceBundle(AbstractMessageInterpolator.CONTRIBUTOR_VALIDATION_MESSAGES)
-                .build();
+        List<String> potentialHibernateValidatorResourceBundles = List.of(
+                AbstractMessageInterpolator.DEFAULT_VALIDATION_MESSAGES,
+                AbstractMessageInterpolator.USER_VALIDATION_MESSAGES,
+                AbstractMessageInterpolator.CONTRIBUTOR_VALIDATION_MESSAGES);
+        List<String> userDefinedHibernateValidatorResourceBundles = new ArrayList<>();
+
+        for (String potentialHibernateValidatorResourceBundle : potentialHibernateValidatorResourceBundles) {
+            if (Thread.currentThread().getContextClassLoader().getResource(potentialHibernateValidatorResourceBundle) != null) {
+                userDefinedHibernateValidatorResourceBundles.add(potentialHibernateValidatorResourceBundle);
+            }
+        }
+
+        if (userDefinedHibernateValidatorResourceBundles.isEmpty()) {
+            return null;
+        }
+
+        NativeImageConfigBuildItem.Builder builder = NativeImageConfigBuildItem.builder();
+        for (String hibernateValidatorResourceBundle : userDefinedHibernateValidatorResourceBundles) {
+            builder.addResourceBundle(hibernateValidatorResourceBundle);
+        }
+
+        return builder.build();
     }
 
     @BuildStep
diff --git a/extensions/resteasy-classic/resteasy-server-common/deployment/src/main/java/io/quarkus/resteasy/server/common/deployment/ResteasyServerCommonProcessor.java b/extensions/resteasy-classic/resteasy-server-common/deployment/src/main/java/io/quarkus/resteasy/server/common/deployment/ResteasyServerCommonProcessor.java
index d65a5a58c02..3595bd4899f 100755
--- a/extensions/resteasy-classic/resteasy-server-common/deployment/src/main/java/io/quarkus/resteasy/server/common/deployment/ResteasyServerCommonProcessor.java
+++ b/extensions/resteasy-classic/resteasy-server-common/deployment/src/main/java/io/quarkus/resteasy/server/common/deployment/ResteasyServerCommonProcessor.java
@@ -88,6 +88,7 @@ public class ResteasyServerCommonProcessor {
     private static final Logger log = Logger.getLogger("io.quarkus.resteasy");
 
     private static final String JAX_RS_APPLICATION_PARAMETER_NAME = "javax.ws.rs.Application";
+    private static final String MESSAGES_RESOURCE_BUNDLE = "messages";
 
     private static final DotName JSONB_ANNOTATION = DotName.createSimple("javax.json.bind.annotation.JsonbAnnotation");
 
@@ -181,8 +182,12 @@ static final class ResteasyConfig {
 
     @BuildStep
     NativeImageConfigBuildItem config() {
+        if (Thread.currentThread().getContextClassLoader().getResource(MESSAGES_RESOURCE_BUNDLE) == null) {
+            return null;
+        }
+
         return NativeImageConfigBuildItem.builder()
-                .addResourceBundle("messages")
+                .addResourceBundle(MESSAGES_RESOURCE_BUNDLE)
                 .build();
     }