Repository: quarkusio/quarkus
Issue: Improve reporting in case JSON cannot be handled due to missing JSONB

I have a JAX-RS method like this:

```
@POST
@Consumes(MediaType.APPLICATION_JSON)
public Response newMeasurement(Measurement measurement) {
    return Response.ok().build();
}
```

`Measurement` should be unmarshalled from the incoming JSON payload. I had forgotten to add the `quarkus-resteasy-jsonb` dependency, though.

This resulted in the following, IMO rather confusing response:

```
HTTP/1.1 415 Unsupported Media Type
Content-Length: 0
```

I'd expect a more meaningful error, perhaps even exception and HTTP status 500 stating, that the request cannot be handled due to lacking unmarshalling capabilities.

Changed files:
extensions/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyCommonProcessor.java
extensions/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyDotNames.java

diff --git a/extensions/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyCommonProcessor.java b/extensions/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyCommonProcessor.java
index b10d7608c23..b052c151d0c 100644
--- a/extensions/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyCommonProcessor.java
+++ b/extensions/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyCommonProcessor.java
@@ -22,11 +22,11 @@
 import org.jboss.jandex.AnnotationInstance;
 import org.jboss.jandex.AnnotationTarget;
 import org.jboss.jandex.AnnotationValue;
+import org.jboss.jandex.AnnotationValue.Kind;
 import org.jboss.jandex.DotName;
 import org.jboss.jandex.IndexView;
 import org.jboss.jandex.MethodInfo;
 import org.jboss.logging.Logger;
-import org.jboss.resteasy.annotations.SseElementType;
 import org.jboss.resteasy.core.MediaTypeMap;
 import org.jboss.resteasy.plugins.interceptors.AcceptEncodingGZIPFilter;
 import org.jboss.resteasy.plugins.interceptors.GZIPDecodingInterceptor;
@@ -56,8 +56,6 @@
 public class ResteasyCommonProcessor {
     private static final Logger LOGGER = Logger.getLogger(ResteasyCommonProcessor.class.getName());
 
-    private static final DotName SSE_ELEMENT_TYPE = DotName.createSimple(SseElementType.class.getName());
-
     private static final ProviderDiscoverer[] PROVIDER_DISCOVERERS = {
             new ProviderDiscoverer(ResteasyDotNames.GET, false, true),
             new ProviderDiscoverer(ResteasyDotNames.HEAD, false, false),
@@ -152,7 +150,8 @@ JaxrsProvidersToRegisterBuildItem setupProviders(BuildProducer<ReflectiveClassBu
         if (!capabilities.isCapabilityPresent(Capabilities.RESTEASY_JSON_EXTENSION)) {
 
             boolean needJsonSupport = restJsonSupportNeeded(indexBuildItem, ResteasyDotNames.CONSUMES)
-                    || restJsonSupportNeeded(indexBuildItem, ResteasyDotNames.PRODUCES);
+                    || restJsonSupportNeeded(indexBuildItem, ResteasyDotNames.PRODUCES)
+                    || restJsonSupportNeeded(indexBuildItem, ResteasyDotNames.RESTEASY_SSE_ELEMENT_TYPE);
             if (needJsonSupport) {
                 LOGGER.warn(
                         "Quarkus detected the need of REST JSON support but you have not provided the necessary JSON " +
@@ -195,7 +194,12 @@ private boolean restJsonSupportNeeded(CombinedIndexBuildItem indexBuildItem, Dot
                 continue;
             }
 
-            final List<String> mediaTypes = Arrays.asList(annotationValue.asStringArray());
+            List<String> mediaTypes = Collections.emptyList();
+            if (annotationValue.kind() == Kind.ARRAY) {
+                mediaTypes = Arrays.asList(annotationValue.asStringArray());
+            } else if (annotationValue.kind() == Kind.STRING) {
+                mediaTypes = Collections.singletonList(annotationValue.asString());
+            }
             return mediaTypes.contains(MediaType.APPLICATION_JSON)
                     || mediaTypes.contains(MediaType.APPLICATION_JSON_PATCH_JSON);
         }
@@ -344,7 +348,8 @@ private static Collection<String> collectInferredProviders(final MediaType media
         if (matches(MediaType.SERVER_SENT_EVENTS_TYPE, mediaType)) {
             final Set<String> additionalProvidersToRegister = new HashSet<>();
             // first check for @SseElementType
-            final AnnotationInstance sseElementTypeAnnInst = targetMethod.annotation(SSE_ELEMENT_TYPE);
+            final AnnotationInstance sseElementTypeAnnInst = targetMethod
+                    .annotation(ResteasyDotNames.RESTEASY_SSE_ELEMENT_TYPE);
             String elementType = null;
             if (sseElementTypeAnnInst != null) {
                 elementType = sseElementTypeAnnInst.value().asString();
diff --git a/extensions/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyDotNames.java b/extensions/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyDotNames.java
index 6f491912bce..021cb3cce0d 100644
--- a/extensions/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyDotNames.java
+++ b/extensions/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyDotNames.java
@@ -44,6 +44,8 @@ public final class ResteasyDotNames {
             .createSimple(org.jboss.resteasy.annotations.jaxrs.HeaderParam.class.getName());
     public static final DotName RESTEASY_MATRIX_PARAM = DotName
             .createSimple(org.jboss.resteasy.annotations.jaxrs.MatrixParam.class.getName());
+    public static final DotName RESTEASY_SSE_ELEMENT_TYPE = DotName
+            .createSimple(org.jboss.resteasy.annotations.SseElementType.class.getName());
 
     public static final IgnoreForReflectionPredicate IGNORE_FOR_REFLECTION_PREDICATE = new IgnoreForReflectionPredicate();