Sorry I thought my example would be illustrative enough, but here is the minimal use case.
With the following producer method: {code} @Produces @ApplicationScoped @Named("properties") static PropertiesComponent configuration() { return new PropertiesComponent("classpath:placeholder.properties"); } {code} When retrieving a contextual reference of that bean: {code} BeanManager manager; Bean<?> bean = manager.resolve(manager.getBeans("properties")); Object proxy = manager.getReference(bean, Object.class, manager.createCreationalContext(bean)); {code}
The proxy {{proxy}} does not implement the given bean type, that is {{(proxy instanceof PropertiesComponent)}} is {{false}}. That happens starting Camel 2.17 as {{PropertiesComponent}} now extends an abstract class. Using the {{@Typed}} annotation enables to work-around the issue though that highlights the issue: {code} @Produces @ApplicationScoped @Named("properties") @Typed(PropertiesComponent.class) static PropertiesComponent configuration() { return new PropertiesComponent("classpath:placeholder.properties"); } {code}
You can find some tests that reproduce the issue as Camel is then unable to retrieve a reference to the {{PropertiesComponent}}: https://github.com/astefanutti/camel/blob/af1b89c01f990a93933c06cebc20effc5f8ef1bf/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/PropertyInjectTest.java#L66 https://github.com/astefanutti/camel/blob/af1b89c01f990a93933c06cebc20effc5f8ef1bf/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/PropertyEndpointTest.java#L65 https://github.com/astefanutti/camel/blob/af1b89c01f990a93933c06cebc20effc5f8ef1bf/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/PropertiesLocationTest.java#L90
In the {{components/camel-cdi}} module, run {{mvn test -Pweld-1.2 -Dtest=PropertyInjectTest}}.
|