From 12ca7ebfbf4d170f6775447cb2658db39c7c10f1 Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Wed, 1 Sep 2021 15:14:01 +0300 Subject: [PATCH] Provide actionable error message when RESTEasy Reactive can't pick Provider constructor Relates to: #19750 Co-authored-by: George Gastaldi --- .../common/runtime/ArcBeanFactory.java | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-common/runtime/src/main/java/io/quarkus/resteasy/reactive/common/runtime/ArcBeanFactory.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive-common/runtime/src/main/java/io/quarkus/resteasy/reactive/common/runtime/ArcBeanFactory.java index 0808558c0ca57..c44b8bb45458c 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive-common/runtime/src/main/java/io/quarkus/resteasy/reactive/common/runtime/ArcBeanFactory.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-common/runtime/src/main/java/io/quarkus/resteasy/reactive/common/runtime/ArcBeanFactory.java @@ -22,17 +22,28 @@ public String toString() { @Override public BeanInstance createInstance() { - BeanContainer.Instance instance = factory.create(); - return new BeanInstance() { - @Override - public T getInstance() { - return instance.get(); + BeanContainer.Instance instance; + try { + instance = factory.create(); + return new BeanInstance() { + @Override + public T getInstance() { + return instance.get(); + } + + @Override + public void close() { + instance.close(); + } + }; + } catch (Exception e) { + if (factory.getClass().getName().contains("DefaultInstanceFactory")) { + throw new IllegalArgumentException( + "Unable to create class '" + targetClassName + + "'. To fix the problem, make sure this class is a CDI bean.", + e); } - - @Override - public void close() { - instance.close(); - } - }; + throw e; + } } }