@ConfigMapping throws ExceptionInInitializerError #24529
-
I am following exactly the quarkus documentation: https://quarkus.io/guides/config-mappings SharingConfigs Interface: @withname("amount") Utils class: As you well noticed, in MappingUtils, i'm trying to access a second configuration interface (RestConfigs), which is similar to SharingConfigs, but there is no problem, because a have already injected RestConfigs in a CDI context, which is annotated with @ApplicationScoped. So, RestConfigs is working as expected. The problem apparently appears, when i do not inject an interface annotated with @ConfigMapping in a CDI context and i'm trying to access it through the SmallRye API. What is the problem? Any ideas to solve this issue? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Yes, unused mappings are removed from Quarkus. Unfortunately, we cannot detect programmatic cases, so you need to add the annotation |
Beta Was this translation helpful? Give feedback.
-
The solution explained work, I just like to know if I can do it using a different approach. I am creating a quarkus extension for a framework, which uses ConfigMappping. Inside my QuarkusProcessor I have tried different approaches to mark the ConfigMapping as Unremovable: @BuildStep
UnremovableBeanBuildItem addUnremovable() {
return UnremovableBeanBuildItem.beanTypes(MyConfigMapping.class);
} I also try the following: @BuildStep
AdditionalBeanBuildItem addUnremovable() {
return AdditionalBeanBuildItem.builder()
.addBeanClass(MyConfigMapping.class)
.setUnremovable()
.build();
} The reason to try the approaches is to separate quarkus dependencies libraries as much as possible from the framework. Both approaches produce the same error. For now, I am using the annotation on the ConfigMapping class, and works as expected. Thank you for the help that you can provide. |
Beta Was this translation helpful? Give feedback.
Yes, unused mappings are removed from Quarkus. Unfortunately, we cannot detect programmatic cases, so you need to add the annotation
@Unremovable
to the mapping class.