Open ashri opened 7 years ago
I could see the possible causes:
javax.annotation.ManagedBean
annotation on your JAX-RS resourcesThat's a usual use case so that'd may be worth sharing it with the CDI user group to get their input.
Besides, it'd be useful debugging the app and see whether the Metrics interceptor that registers metrics at bean instantiation is actually called: https://github.com/astefanutti/metrics-cdi/blob/29e7bac497513de420543497612180331cc5d1b3/impl/src/main/java/io/astefanutti/metrics/cdi/MetricsInterceptor.java#L55. That'd would be a start to identify the root cause.
Hi,
Sorry it took me so long to get back to this issue but I had a few moments today and finally got to some debugging.
I focused on debugging within TomEE 7.0.4 as that ran but didn't record timings. I also update the metrics-cdi dependency to 1.4.0.
The MetricsInterceptor is being called for the @AroundConstruct method you mention. The MetricsRegistry is the same registry on each invocation and the @Timed annotation is discovered and registered as expected.
However the TimedInterceptor is never called when run under TomEE. None of the annotated methods in that class are called. They are called as expected when run under Wildfly.
If there is a better place to ask these questions I would welcome some guidance. I tried looking at the cdi-dev mailing list but wasn't convinced that was a good place to ask.
Thanks for the help.
Thanks for the update. The only difference that I see is that the TimedInterceptor
interceptor binding is added programmatically: https://github.com/astefanutti/metrics-cdi/blob/cc598215f10a0726191e19c02c7b1c117e905e5b/impl/src/main/java/io/astefanutti/metrics/cdi/MetricsExtension.java#L77
That may be a lead.
Maybe the best place to start asking about that issue is the TomEE mailing list. Otherwise you could try isolating a minimal use case with programmatically added interceptor binding and fill an issue in TomEE JIRA.
Thanks. I will post a message to the TomEE mailing list later today and see where it goes.
I'm trying to use this library with payara-micro 174, I also see it failing to deploy the app with the same error if I try @ashri 's test app. I think it can't find the MetricRegistry - either if I use the default one registered by the library or I provide my own one with a producer method.
org.jboss.weld.exceptions.IllegalArgumentException: WELD-001456: Argument bean must not be null
at org.jboss.weld.util.Preconditions.checkArgumentNotNull(Preconditions.java:40)
at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:799)
at org.jboss.weld.util.ForwardingBeanManager.getReference(ForwardingBeanManager.java:61)
at org.jboss.weld.bean.builtin.BeanManagerProxy.getReference(BeanManagerProxy.java:85)
at io.astefanutti.metrics.cdi.MetricsExtension.getReference(MetricsExtension.java:137)
at io.astefanutti.metrics.cdi.MetricsExtension.getReference(MetricsExtension.java:132)
at io.astefanutti.metrics.cdi.MetricsExtension.configuration(MetricsExtension.java:106)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:88)
at org.jboss.weld.injection.MethodInvocationStrategy$SpecialParamPlusBeanManagerStrategy.invoke(MethodInvocationStrategy.java:144)
at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:299)
at org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(ExtensionObserverMethodImpl.java:124)
at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:277)
at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:255)
at org.jboss.weld.event.ObserverNotifier.notifySyncObservers(ObserverNotifier.java:269)
at org.jboss.weld.event.ObserverNotifier.notify(ObserverNotifier.java:258)
at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:154)
at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:148)
at org.jboss.weld.bootstrap.events.AbstractContainerEvent.fire(AbstractContainerEvent.java:53)
at org.jboss.weld.bootstrap.events.AbstractDeploymentContainerEvent.fire(AbstractDeploymentContainerEvent.java:35)
at org.jboss.weld.bootstrap.events.AfterDeploymentValidationImpl.fire(AfterDeploymentValidationImpl.java:28)
at org.jboss.weld.bootstrap.WeldStartup.validateBeans(WeldStartup.java:487)
at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:90)
at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:261)
at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131)
@grommitz thanks for the info. I'll try debugging with payara-micro ASAP then.
I have a very basic example application using Metrics-CDI found here:
https://github.com/ashri/metrics-cdi-jaxrs
This application just has a hello-world style endpoint which is annotated with
@Timer
. The application is configured to log the metrics to the console every 5 seconds.To test the application, first build it with
mvn package
then after deployment to an app server, runcurl http://localhost:8080/metrics-cdi-jaxrs
If you deploy the example to Wildfly 10.1, the application logs metrics as expected.
If you deploy the example to TomEE 7.0.2, the application does log metrics but they are always 0.
If you deploy the example to Payara 172, the application fails to start due to being unable to find the appropriate beans.
I have no idea what is the root cause of the problem.
Payara has a more recent version of the Weld library. TomEE may not be cross-polinating managed beans across the BeanManagers meaning the one injected in the app is not the same MetricRegistry bean the metrics are logging to (wild speculation).
Any assistance with this issue would be greatly appreciated.