You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openwebbeans.apache.org by "Richard Zowalla (Jira)" <ji...@apache.org> on 2024/10/14 06:45:00 UTC

[jira] [Updated] (OWB-1441) Adding a User-defined Interceptor Bean via CDI Extension fails due to missing no-arg constructor

     [ https://issues.apache.org/jira/browse/OWB-1441?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Richard Zowalla updated OWB-1441:
---------------------------------
    Attachment: OWB-1441.patch

> Adding a User-defined Interceptor Bean via CDI Extension fails due to missing no-arg constructor
> ------------------------------------------------------------------------------------------------
>
>                 Key: OWB-1441
>                 URL: https://issues.apache.org/jira/browse/OWB-1441
>             Project: OpenWebBeans
>          Issue Type: Bug
>    Affects Versions: 4.0.2
>            Reporter: Richard Zowalla
>            Assignee: Richard Zowalla
>            Priority: Major
>         Attachments: OWB-1441.patch
>
>
> Given the following CDI extension:
> [https://github.com/smallrye/smallrye-opentelemetry/blob/main/implementation/cdi/src/main/java/io/smallrye/opentelemetry/implementation/cdi/OpenTelemetryExtension.java#L34]
> OWB will fail with the following stacktrace:
>  
> {code:java}
> Caused by: org.apache.webbeans.exception.WebBeansConfigurationException: Error while sending SystemEvent to a CDI Extension! org.apache.webbeans.portable.events.discovery.AfterBeanDiscoveryImpl@576e2324
> 		at org.apache.webbeans.event.NotificationManager.onWebBeansException(NotificationManager.java:1079)
> 		at org.apache.webbeans.event.NotificationManager.doFireSync(NotificationManager.java:1026)
> 		at org.apache.webbeans.event.NotificationManager.doFireEvent(NotificationManager.java:952)
> 		at org.apache.webbeans.event.NotificationManager.fireEvent(NotificationManager.java:928)
> 		at org.apache.webbeans.container.BeanManagerImpl.fireEvent(BeanManagerImpl.java:505)
> 		at org.apache.webbeans.container.BeanManagerImpl.fireLifecycleEvent(BeanManagerImpl.java:500)
> 		at org.apache.webbeans.config.BeansDeployer.fireAfterBeanDiscoveryEvent(BeansDeployer.java:885)
> 		at org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:315)
> 		at org.apache.openejb.cdi.OpenEJBLifecycle.startApplication(OpenEJBLifecycle.java:196)
> 		... 69 more
> 	Caused by: org.apache.webbeans.exception.WebBeansException: org.apache.webbeans.exception.WebBeansCreationException: No default constructor for io.smallrye.opentelemetry.implementation.cdi.WithSpanInterceptorBean
> 		at org.apache.webbeans.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:377)
> 		at org.apache.webbeans.event.NotificationManager.invokeObserverMethod(NotificationManager.java:1146)
> 		at org.apache.webbeans.event.NotificationManager.doFireSync(NotificationManager.java:1009)
> 		... 76 more
> 	Caused by: org.apache.webbeans.exception.WebBeansCreationException: No default constructor for io.smallrye.opentelemetry.implementation.cdi.WithSpanInterceptorBean
> 		at org.apache.webbeans.portable.InjectionTargetImpl.createConstructor(InjectionTargetImpl.java:398)
> 		at org.apache.webbeans.portable.InjectionTargetImpl.getConstructor(InjectionTargetImpl.java:375)
> 		at org.apache.webbeans.portable.InjectionTargetImpl.defineLifecycleInterceptors(InjectionTargetImpl.java:144)
> 		at org.apache.webbeans.portable.AbstractProducer.defineInterceptorStack(AbstractProducer.java:95)
> 		at org.apache.webbeans.util.WebBeansUtil.defineManagedBeanWithoutFireEvents(WebBeansUtil.java:1193)
> 		at org.apache.webbeans.portable.events.discovery.AfterBeanDiscoveryImpl.addBean(AfterBeanDiscoveryImpl.java:116)
> 		at io.smallrye.opentelemetry.implementation.cdi.OpenTelemetryExtension.afterBeanDiscovery(OpenTelemetryExtension.java:34)
> 		at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 		at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
> 		at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 		at java.base/java.lang.reflect.Method.invoke(Method.java:568)
> 		at org.apache.webbeans.event.ObserverMethodImpl.invoke(ObserverMethodImpl.java:410)
> 		at org.apache.webbeans.event.ContainerEventObserverMethodImpl.invoke(ContainerEventObserverMethodImpl.java:86)
> 		at org.apache.webbeans.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:371)
> 		... 78 more {code}
> The extension dynamically adds a bean via addBean(myCustomBean) and subsequently fails with the stacktrace above.
> There is some more detail in the Slack discussion with [~rmannibucau] : [https://the-asf.slack.com/archives/C9QU5UHC5/p1717531645315229?thread_ts=1717529714.645939&cid=C9QU5UHC5]
> According to his analysis, it seems, that 
>  * "when a custom bean is passed we should use it at runtime, here we just use another one and rely on the original bean as static specs."
>  * "we should never replace an user Bean impl by an owb ManagedBean"
>  * "this is why we end in producer being an interceptor friendly producer (injection target impl). if we respect user bean contract it will not happen"
> Relevant Code:
> [https://github.com/apache/openwebbeans/blob/main/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java#L116 |https://github.com/apache/openwebbeans/blob/main/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java#L116]
> [~rmannibucau] Feel free to add more context here. Don't know if I got it right from our conversation in Slack.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)