Wildfly 16 Microprofile Metrics - can not create Tags at runtime
rsoika May 26, 2019 4:34 AMI am trying out the Microprofile Metrics API in Wildfly 16.0.0. But I run into problem with a simple counter metric. The following code fails:
.... @Inject @RegistryType(type=MetricRegistry.Type.APPLICATION) MetricRegistry metricRegistry; .... Tag myTag=new Tag("type","abc"); // throws Exception ...!! Counter myCoutner = metricRegistry.counter("my_coutner", myTag); ....
The problem is the line:
org.eclipse.microprofile.metrics.Tag myTag=new Tag("type","abc");
This line causes the following exception:
Caused by: java.lang.NoClassDefFoundError: org/eclipse/microprofile/metrics/Tag imixssample-app_1 | at deployment.imixs-jsf-example-4.2.2.war//org.imixs.workflow.engine.MetricService.buildWorkitemMetric(MetricService.java:225) imixssample-app_1 | at deployment.imixs-jsf-example-4.2.2.war//org.imixs.workflow.engine.MetricService.onProcessingEvent(MetricService.java:136) imixssample-app_1 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) imixssample-app_1 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) imixssample-app_1 | at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) imixssample-app_1 | at java.base/java.lang.reflect.Method.invoke(Method.java:564) imixssample-app_1 | at org.jboss.weld.core@3.1.0.Final//org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:95) imixssample-app_1 | ... 149 more imixssample-app_1 | Caused by: java.lang.ClassNotFoundException: org.eclipse.microprofile.metrics.Tag from [Module "deployment.imixs-jsf-example-4.2.2.war" from Service Module Loader] imixssample-app_1 | at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:255) imixssample-app_1 | at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:410) imixssample-app_1 | at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398) imixssample-app_1 | at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116) imixssample-app_1 | ... 156 more
When I create the counter without Tags than the metric works fine.
The method itself is called within an CDI Event - can this be the problem?
Thanks for any help
===
Ralph