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 0808558c0ca57b..68c8faf9d1e7b2 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,27 @@ 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 this class is a CDI bean.", + e); } - - @Override - public void close() { - instance.close(); - } - }; + throw e; + } } }