提问者:小点点

Wildfly 26上的Microprofile指标问题


我目前正在从Wildfly 20升级到Wildfly 26。标准. xml无法启动,因为注入了Metric注册表和新丢失的microprofile.metrics-小扩展(已经在以下描述:MicroProfile Metrics不显示Wildfly 25上的自定义指标)。但是如果我启动独立-microprofile.xml或添加扩展(请参阅下面的CLI命令),我遇到了同样的错误。

也许是密钥斗篷集成解决方法是相互冲突的。Wildfly内部OIDC适配器实际上不在仅承载模式下工作。所以我安装了当前的密钥斗篷客户端(密钥斗篷-oidc-Wildfly-适配器-16.1.1)和解决方法(参见最后的代码模板)。

2022-02-21 12:44:09,176 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC000001: Failed to start service jboss.deployment.unit."xyz.war".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."xyz.war".WeldStartService: Failed to start service
        at org.jboss.msc@1.4.13.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1731)
        at org.jboss.msc@1.4.13.Final//org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1559)
        at org.jboss.threads@2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
        at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
        at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
        at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
        at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.jboss.weld.exceptions.DeploymentException: SRMET00013: Description is different from the description in previous usage
        at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.bootstrap.events.AbstractDeploymentContainerEvent.fire(AbstractDeploymentContainerEvent.java:38)
        at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.bootstrap.events.AfterDeploymentValidationImpl.fire(AfterDeploymentValidationImpl.java:28)
        at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.bootstrap.WeldStartup.validateBeans(WeldStartup.java:510)
        at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:93)
        at org.jboss.as.weld@26.0.1.Final//org.jboss.as.weld.WeldStartService.start(WeldStartService.java:98)
        at org.jboss.msc@1.4.13.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1739)
        at org.jboss.msc@1.4.13.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1701)
        ... 6 more
Caused by: java.lang.IllegalStateException: SRMET00013: Description is different from the description in previous usage
        at io.smallrye.metrics//io.smallrye.metrics.MetricsRegistryImpl.verifyMetadataEquality(MetricsRegistryImpl.java:188)
        at io.smallrye.metrics//io.smallrye.metrics.MetricsRegistryImpl.get(MetricsRegistryImpl.java:459)
        at io.smallrye.metrics//io.smallrye.metrics.MetricsRegistryImpl.get(MetricsRegistryImpl.java:402)
        at io.smallrye.metrics//io.smallrye.metrics.MetricsRegistryImpl.timer(MetricsRegistryImpl.java:371)
        at io.smallrye.metrics//io.smallrye.metrics.setup.MetricsMetadata.registerMetrics(MetricsMetadata.java:111)
        at io.smallrye.metrics//io.smallrye.metrics.setup.MetricCdiInjectionExtension.registerMetrics(MetricCdiInjectionExtension.java:186)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:95)
        at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.injection.MethodInvocationStrategy$SpecialParamPlusBeanManagerStrategy.invoke(MethodInvocationStrategy.java:187)
        at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:330)
        at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(ExtensionObserverMethodImpl.java:123)
        at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:308)
        at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:286)
        at javax.enterprise.api//javax.enterprise.inject.spi.ObserverMethod.notify(ObserverMethod.java:124)
        at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.util.Observers.notify(Observers.java:166)
        at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.event.ObserverNotifier.notifySyncObservers(ObserverNotifier.java:285)
        at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.event.ObserverNotifier.notify(ObserverNotifier.java:273)
        at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:177)
        at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:171)
        at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.bootstrap.events.AbstractContainerEvent.fire(AbstractContainerEvent.java:53)
        at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.bootstrap.events.AbstractDeploymentContainerEvent.fire(AbstractDeploymentContainerEvent.java:35)

CLI-命令来扩展标准. xml

wildfly/bin/jboss-cli.sh -c "/extension=org.wildfly.extension.microprofile.metrics-smallrye:add()"
wildfly/bin/jboss-cli.sh -c "/subsystem=microprofile-metrics-smallrye:add()"

wildfly/bin/jboss-cli.sh -c "/extension=org.wildfly.extension.microprofile.fault-tolerance-smallrye:add()"
wildfly/bin/jboss-cli.sh -c "/subsystem=microprofile-fault-tolerance-smallrye:add()"

OIDC-解决方法(安装keyCloak客户端)

embed-server --server-config=${server.config:standalone.xml}

batch
/subsystem=undertow/application-security-domain=other:undefine-attribute(name=security-domain)
/subsystem=undertow/application-security-domain=other:write-attribute(name=http-authentication-factory,value=keycloak-http-authentication)
run-batch

/subsystem=ejb3/application-security-domain=other:write-attribute(name=security-domain,value=KeycloakDomain)

reload


共3个答案

匿名用户

哦,我花了几个小时来解决这个问题…但是在写了这篇文章几分钟后,我发现了“坏人”。Microprofile版本3.3(在Wildfly 20上)忽略了接口方法的注释(如@Timed)。新的版本4.1(Wildfly 26)将它们视为…

很容易,之后:)

边际注释:如果您在Wildfly上部署了多个WAR,并且其中一个正在使用另一个的公共API,那么您将遇到热部署问题。我假设,在我的情况下,它发生是因为我将Timed-注释放在了实现类而不是用作ResteasyClient-proxy的接口上。每次我在rest-api定义的WAR之后部署依赖的WAR时,我都会遇到一个例外:没有度量映射。rest-api定义WAR的重新部署解决了这个问题:)

匿名用户

通常使用匿名用户(prometheus刮刀)查询 /metricsendpoint,这意味着您可能必须启用MONITOR角色以包含所有。这样,对 /metrics的匿名访问将能够读取额外的线程数据。

^^这个配置的安全影响我不确定。

匿名用户

在我的情况下,我在@Timed(name="")中使用其他方法复制了名称……