8 Replies Latest reply on Sep 30, 2019 2:44 AM by Timon Zilles

    NullPointerException: org.wildfly.extension.microprofile.metrics.MetricCollector

    Timon Zilles Newbie

      Used WildFly: 17.0.1.Final

       

      1. Steps to reproduce: Start WildFly

      2. Deploy simple WAR with an Entity (in my case"MyEntity"), a web.xml and persistence.xml.

      3. Access metrics using *hostname*:9990/metrics

       

      Used dependencies:

      <dependency>
           <groupId>org.wildfly</groupId>
           <artifactId>wildfly-parent</artifactId>
           <version>17.0.1.Final</version>
           <type>pom</type>
           <scope>import</scope>
      </dependency>
      
      
      <dependency>
           <groupId>javax.persistence</groupId>
           <artifactId>javax.persistence-api</artifactId>
           <version>2.2</version>
      </dependency>
      
      
      

       

      Error log:

       

      11:29:02,376 ERROR [org.jboss.as.controller.management-operation] (management I/O-1) WFLYCTL0013: Operation ("read-attribute") failed - address: ([
          ("deployment" => "test-0.0.1-SNAPSHOT.war"),
          ("subsystem" => "jpa"),
          ("hibernate-persistence-unit" => "test-0.0.1-SNAPSHOT.war#my-persistence-unit"),
          ("entity-cache" => "test.MyEntity")
      ]): java.lang.NullPointerException
      at org.hibernate@5.3.10.Final//org.hibernate.stat.internal.StatisticsImpl.lambda$getCacheRegionStatistics$6(StatisticsImpl.java:633)
      at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1705)
      at org.hibernate@5.3.10.Final//org.hibernate.stat.internal.StatisticsImpl.getCacheRegionStatistics(StatisticsImpl.java:625)
      at org.hibernate@5.3.10.Final//org.hibernate.stat.internal.StatisticsImpl.getSecondLevelCacheStatistics(StatisticsImpl.java:646)
      at org.hibernate@5.3.10.Final//org.hibernate.stat.internal.StatisticsImpl.getSecondLevelCacheStatistics(StatisticsImpl.java:32)
      at org.hibernate.jipijapa-hibernate5-3@17.0.1.Final//org.jboss.as.jpa.hibernate5.management.HibernateEntityCacheStatistics.getStatistics(HibernateEntityCacheStatistics.java:94)
      at org.hibernate.jipijapa-hibernate5-3@17.0.1.Final//org.jboss.as.jpa.hibernate5.management.HibernateEntityCacheStatistics$2.invoke(HibernateEntityCacheStatistics.java:110)
      at org.hibernate.jipijapa-hibernate5-3@17.0.1.Final//org.jboss.as.jpa.hibernate5.management.HibernateAbstractStatistics.getValue(HibernateAbstractStatistics.java:99)
      at org.jboss.as.jpa@17.0.1.Final//org.jboss.as.jpa.management.ManagementResourceDefinition$1.handle(ManagementResourceDefinition.java:130)
      at org.jboss.as.jpa@17.0.1.Final//org.jboss.as.jpa.management.ManagementResourceDefinition$AbstractMetricsHandler.executeRuntimeStep(ManagementResourceDefinition.java:268)
      at org.jboss.as.controller@9.0.2.Final//org.jboss.as.controller.AbstractRuntimeOnlyHandler$1.execute(AbstractRuntimeOnlyHandler.java:59)
      at org.jboss.as.controller@9.0.2.Final//org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:999)
      at org.jboss.as.controller@9.0.2.Final//org.jboss.as.controller.AbstractOperationContext.processStages(AbstractOperationContext.java:743)
      at org.jboss.as.controller@9.0.2.Final//org.jboss.as.controller.AbstractOperationContext.executeOperation(AbstractOperationContext.java:467)
      at org.jboss.as.controller@9.0.2.Final//org.jboss.as.controller.OperationContextImpl.executeOperation(OperationContextImpl.java:1412)
      at org.jboss.as.controller@9.0.2.Final//org.jboss.as.controller.ModelControllerImpl.internalExecute(ModelControllerImpl.java:423)
      at org.jboss.as.controller@9.0.2.Final//org.jboss.as.controller.ModelControllerImpl.lambda$execute$1(ModelControllerImpl.java:243)
      at org.wildfly.security.elytron-private@1.9.1.Final//org.wildfly.security.auth.server.SecurityIdentity.runAs(SecurityIdentity.java:289)
      at org.wildfly.security.elytron-private@1.9.1.Final//org.wildfly.security.auth.server.SecurityIdentity.runAs(SecurityIdentity.java:255)
      at org.jboss.as.controller@9.0.2.Final//org.jboss.as.controller.ModelControllerImpl.execute(ModelControllerImpl.java:243)
      at org.jboss.as.controller@9.0.2.Final//org.jboss.as.controller.ModelControllerClientFactoryImpl$LocalClient.executeInModelControllerCl(ModelControllerClientFactoryImpl.java:259)
      at org.jboss.as.controller@9.0.2.Final//org.jboss.as.controller.ModelControllerClientFactoryImpl$LocalClient.access$300(ModelControllerClientFactoryImpl.java:114)
      at org.jboss.as.controller@9.0.2.Final//org.jboss.as.controller.ModelControllerClientFactoryImpl$LocalClient$1.run(ModelControllerClientFactoryImpl.java:152)
      at org.jboss.as.controller@9.0.2.Final//org.jboss.as.controller.ModelControllerClientFactoryImpl$LocalClient$1.run(ModelControllerClientFactoryImpl.java:147)
      at org.wildfly.security.elytron-private@1.9.1.Final//org.wildfly.security.auth.server.SecurityIdentity.runAs(SecurityIdentity.java:289)
      at org.wildfly.security.elytron-private@1.9.1.Final//org.wildfly.security.auth.server.SecurityIdentity.runAs(SecurityIdentity.java:255)
      at org.jboss.as.controller@9.0.2.Final//org.jboss.as.controller.AccessAuditContext.doAs(AccessAuditContext.java:198)
      at org.jboss.as.controller@9.0.2.Final//org.jboss.as.controller.AccessAuditContext.doAs(AccessAuditContext.java:175)
      at org.jboss.as.controller@9.0.2.Final//org.jboss.as.controller.ModelControllerClientFactoryImpl$LocalClient.executeOperation(ModelControllerClientFactoryImpl.java:147)
      at org.jboss.as.controller@9.0.2.Final//org.jboss.as.controller.LocalModelControllerClient.execute(LocalModelControllerClient.java:54)
      at org.jboss.as.controller@9.0.2.Final//org.jboss.as.controller.LocalModelControllerClient.execute(LocalModelControllerClient.java:39)
      at org.wildfly.extension.microprofile.metrics-smallrye@17.0.1.Final//org.wildfly.extension.microprofile.metrics.MetricCollector.lambda$collectResourceMetrics0$0(MetricCollector.java:140)
      at org.wildfly.extension.microprofile.metrics-smallrye@17.0.1.Final//org.wildfly.extension.microprofile.metrics.PrometheusCollector.collect(PrometheusCollector.java:50)
      at io.prometheus.simpleclient//io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.findNextElement(CollectorRegistry.java:183)
      at io.prometheus.simpleclient//io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.(CollectorRegistry.java:147)
      at io.prometheus.simpleclient//io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.(CollectorRegistry.java:168)
      at io.prometheus.simpleclient//io.prometheus.client.CollectorRegistry.metricFamilySamples(CollectorRegistry.java:130)
      at org.wildfly.extension.microprofile.metrics-smallrye@17.0.1.Final//org.wildfly.extension.microprofile.metrics.MetricsContextService$1.handleRequest(MetricsContextService.java:100)
      at org.jboss.as.domain-http-interface@9.0.2.Final//org.jboss.as.domain.http.server.security.RealmReadinessHandler.handleRequest(RealmReadinessHandler.java:51)
      at org.jboss.as.domain-http-interface@9.0.2.Final//org.jboss.as.domain.http.server.security.ServerErrorReadinessHandler.handleRequest(ServerErrorReadinessHandler.java:35)
      at io.undertow.core@2.0.21.Final//io.undertow.server.handlers.PathHandler.handleRequest(PathHandler.java:91)
      at io.undertow.core@2.0.21.Final//io.undertow.server.handlers.ChannelUpgradeHandler.handleRequest(ChannelUpgradeHandler.java:211)
      at io.undertow.core@2.0.21.Final//io.undertow.server.handlers.cache.CacheHandler.handleRequest(CacheHandler.java:92)
      at io.undertow.core@2.0.21.Final//io.undertow.server.handlers.error.SimpleErrorPageHandler.handleRequest(SimpleErrorPageHandler.java:78)
      at io.undertow.core@2.0.21.Final//io.undertow.server.handlers.CanonicalPathHandler.handleRequest(CanonicalPathHandler.java:49)
      at org.jboss.as.domain-http-interface@9.0.2.Final//org.jboss.as.domain.http.server.ManagementHttpRequestHandler.handleRequest(ManagementHttpRequestHandler.java:57)
      at org.jboss.as.domain-http-interface@9.0.2.Final//org.jboss.as.domain.http.server.cors.CorsHttpHandler.handleRequest(CorsHttpHandler.java:75)
      at org.jboss.as.domain-http-interface@9.0.2.Final//org.jboss.as.domain.http.server.ManagementHttpServer$UpgradeFixHandler.handleRequest(ManagementHttpServer.java:664)
      at io.undertow.core@2.0.21.Final//io.undertow.server.Connectors.executeRootHandler(Connectors.java:364)
      at io.undertow.core@2.0.21.Final//io.undertow.server.protocol.http.HttpReadListener.handleEventWithNoRunningRequest(HttpReadListener.java:255)
      at io.undertow.core@2.0.21.Final//io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:136)
      at io.undertow.core@2.0.21.Final//io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:59)
      at org.jboss.xnio@3.7.2.Final//org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
      at org.jboss.xnio@3.7.2.Final//org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66)
      at org.jboss.xnio.nio@3.7.2.Final//org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:89)
      at org.jboss.xnio.nio@3.7.2.Final//org.xnio.nio.WorkerThread.run(WorkerThread.java:591)
      
      
      11:29:02,381 ERROR [io.undertow.request] (management I/O-1) UT005071: Undertow request failed HttpServerExchange{ GET /metrics}: java.lang.IllegalStateException: WFLYMETRICS0003: Unable to read attribute second-level-cache-hit-count on [
          ("subsystem" => "jpa"),
          ("hibernate-persistence-unit" => "test-0.0.1-SNAPSHOT.war#my-persistence-unit"),
          ("entity-cache" => "test.MyEntity")
      ]: "WFLYCTL0158: Operation handler failed: java.lang.NullPointerException".
      at org.wildfly.extension.microprofile.metrics-smallrye@17.0.1.Final//org.wildfly.extension.microprofile.metrics.MetricCollector.lambda$collectResourceMetrics0$0(MetricCollector.java:143)
      at org.wildfly.extension.microprofile.metrics-smallrye@17.0.1.Final//org.wildfly.extension.microprofile.metrics.PrometheusCollector.collect(PrometheusCollector.java:50)
      at io.prometheus.simpleclient//io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.findNextElement(CollectorRegistry.java:183)
      at io.prometheus.simpleclient//io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.(CollectorRegistry.java:147)
      at io.prometheus.simpleclient//io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.(CollectorRegistry.java:168)
      at io.prometheus.simpleclient//io.prometheus.client.CollectorRegistry.metricFamilySamples(CollectorRegistry.java:130)
      at org.wildfly.extension.microprofile.metrics-smallrye@17.0.1.Final//org.wildfly.extension.microprofile.metrics.MetricsContextService$1.handleRequest(MetricsContextService.java:100)
      at org.jboss.as.domain-http-interface@9.0.2.Final//org.jboss.as.domain.http.server.security.RealmReadinessHandler.handleRequest(RealmReadinessHandler.java:51)
      at org.jboss.as.domain-http-interface@9.0.2.Final//org.jboss.as.domain.http.server.security.ServerErrorReadinessHandler.handleRequest(ServerErrorReadinessHandler.java:35)
      at io.undertow.core@2.0.21.Final//io.undertow.server.handlers.PathHandler.handleRequest(PathHandler.java:91)
      at io.undertow.core@2.0.21.Final//io.undertow.server.handlers.ChannelUpgradeHandler.handleRequest(ChannelUpgradeHandler.java:211)
      at io.undertow.core@2.0.21.Final//io.undertow.server.handlers.cache.CacheHandler.handleRequest(CacheHandler.java:92)
      at io.undertow.core@2.0.21.Final//io.undertow.server.handlers.error.SimpleErrorPageHandler.handleRequest(SimpleErrorPageHandler.java:78)
      at io.undertow.core@2.0.21.Final//io.undertow.server.handlers.CanonicalPathHandler.handleRequest(CanonicalPathHandler.java:49)
      at org.jboss.as.domain-http-interface@9.0.2.Final//org.jboss.as.domain.http.server.ManagementHttpRequestHandler.handleRequest(ManagementHttpRequestHandler.java:57)
      at org.jboss.as.domain-http-interface@9.0.2.Final//org.jboss.as.domain.http.server.cors.CorsHttpHandler.handleRequest(CorsHttpHandler.java:75)
      at org.jboss.as.domain-http-interface@9.0.2.Final//org.jboss.as.domain.http.server.ManagementHttpServer$UpgradeFixHandler.handleRequest(ManagementHttpServer.java:664)
      at io.undertow.core@2.0.21.Final//io.undertow.server.Connectors.executeRootHandler(Connectors.java:364)
      at io.undertow.core@2.0.21.Final//io.undertow.server.protocol.http.HttpReadListener.handleEventWithNoRunningRequest(HttpReadListener.java:255)
      at io.undertow.core@2.0.21.Final//io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:136)
      at io.undertow.core@2.0.21.Final//io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:59)
      at org.jboss.xnio@3.7.2.Final//org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
      at org.jboss.xnio@3.7.2.Final//org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66)
      at org.jboss.xnio.nio@3.7.2.Final//org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:89)
      at org.jboss.xnio.nio@3.7.2.Final//org.xnio.nio.WorkerThread.run(WorkerThread.java:591)

       

       

      Is there a way to solve this problem without activating the hibernate query cache? Respectively is this property required to resolve metrics?

       

      Using the following persistence.xml no error is thrown:

       

      <persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.2"
      xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd">
      
           <persistence-unit name="my-persistence-unit">
                <properties>
                     <property name="hibernate.cache.use_query_cache" value="true" />
                </properties>
           </persistence-unit>
      </persistence>
      

       

      Hint: The error is also reproducible with WildFly 18.0.0.Beta1, which uses Hibernate 5.3.11.Final.

        • 1. Re: NullPointerException: org.wildfly.extension.microprofile.metrics.MetricCollector
          Brian Stansberry Master

          This looks like [HHH-13505] NullPointerException thrown by StatisticsImpl#getCacheRegionStatistics - Hibernate JIRA which is fixed in WildFly 18.0.0.Beta1.

           

          I haven't tried but using <property name="hibernate.cache.use_second_level_cache" value="false" /> instead of enabling the query cache may work around the problem.

          • 2. Re: NullPointerException: org.wildfly.extension.microprofile.metrics.MetricCollector
            Brian Stansberry Master

            Hmm, I just saw your last sentence about this being reproducible in WildFly 18.0.0.Beta1.

             

            If you can post a stack trace showing that problem, please do as it must be different in some way.

            • 3. Re: NullPointerException: org.wildfly.extension.microprofile.metrics.MetricCollector
              Timon Zilles Newbie

              EDIT: I can confirm that setting the value for hibernate.cache.use_query_cache to true OR false the error doesn't show anymore! Neither in WildFly 17 nor in WildFly 18.

              Thank you for this hint!

               

              Here the stacktrace of WildFly 18.0.0.Beta1 (without the set of the use_query_cache property)

               

              08:48:54,935 ERROR [org.jboss.as.controller.management-operation] (management I/O-1) WFLYCTL0013: Operation ("read-attribute") failed - address: ([
                  ("deployment" => "test-0.0.1-SNAPSHOT.war"),
                  ("subsystem" => "jpa"),
                  ("hibernate-persistence-unit" => "test-0.0.1-SNAPSHOT.war#my-persistence-unit"),
                  ("entity-cache" => "test.MyEntity")
              ]): java.lang.NullPointerException
              at java.base/java.util.concurrent.ConcurrentHashMap.putVal(ConcurrentHashMap.java:1011)
              at java.base/java.util.concurrent.ConcurrentHashMap.putIfAbsent(ConcurrentHashMap.java:1541)
              at org.hibernate@5.3.11.Final//org.hibernate.stat.internal.StatsNamedContainer.getOrCompute(StatsNamedContainer.java:57)
              at org.hibernate@5.3.11.Final//org.hibernate.stat.internal.StatisticsImpl.getCacheRegionStatistics(StatisticsImpl.java:624)
              at org.hibernate@5.3.11.Final//org.hibernate.stat.internal.StatisticsImpl.getSecondLevelCacheStatistics(StatisticsImpl.java:650)
              at org.hibernate@5.3.11.Final//org.hibernate.stat.internal.StatisticsImpl.getSecondLevelCacheStatistics(StatisticsImpl.java:30)
              at org.hibernate.jipijapa-hibernate5-3@18.0.0.Beta1//org.jboss.as.jpa.hibernate5.management.HibernateEntityCacheStatistics.getStatistics(HibernateEntityCacheStatistics.java:94)
              at org.hibernate.jipijapa-hibernate5-3@18.0.0.Beta1//org.jboss.as.jpa.hibernate5.management.HibernateEntityCacheStatistics$2.invoke(HibernateEntityCacheStatistics.java:110)
              at org.hibernate.jipijapa-hibernate5-3@18.0.0.Beta1//org.jboss.as.jpa.hibernate5.management.HibernateAbstractStatistics.getValue(HibernateAbstractStatistics.java:99)
              at org.jboss.as.jpa@18.0.0.Beta1//org.jboss.as.jpa.management.ManagementResourceDefinition$1.handle(ManagementResourceDefinition.java:130)
              at org.jboss.as.jpa@18.0.0.Beta1//org.jboss.as.jpa.management.ManagementResourceDefinition$AbstractMetricsHandler.executeRuntimeStep(ManagementResourceDefinition.java:268)
              at org.jboss.as.controller@10.0.0.Beta6//org.jboss.as.controller.AbstractRuntimeOnlyHandler$1.execute(AbstractRuntimeOnlyHandler.java:59)
              at org.jboss.as.controller@10.0.0.Beta6//org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:999)
              at org.jboss.as.controller@10.0.0.Beta6//org.jboss.as.controller.AbstractOperationContext.processStages(AbstractOperationContext.java:743)
              at org.jboss.as.controller@10.0.0.Beta6//org.jboss.as.controller.AbstractOperationContext.executeOperation(AbstractOperationContext.java:467)
              at org.jboss.as.controller@10.0.0.Beta6//org.jboss.as.controller.OperationContextImpl.executeOperation(OperationContextImpl.java:1413)
              at org.jboss.as.controller@10.0.0.Beta6//org.jboss.as.controller.ModelControllerImpl.internalExecute(ModelControllerImpl.java:423)
              at org.jboss.as.controller@10.0.0.Beta6//org.jboss.as.controller.ModelControllerImpl.lambda$execute$1(ModelControllerImpl.java:243)
              at org.wildfly.security.elytron-private@1.10.0.Final//org.wildfly.security.auth.server.SecurityIdentity.runAs(SecurityIdentity.java:289)
              at org.wildfly.security.elytron-private@1.10.0.Final//org.wildfly.security.auth.server.SecurityIdentity.runAs(SecurityIdentity.java:255)
              at org.jboss.as.controller@10.0.0.Beta6//org.jboss.as.controller.ModelControllerImpl.execute(ModelControllerImpl.java:243)
              at org.jboss.as.controller@10.0.0.Beta6//org.jboss.as.controller.ModelControllerClientFactoryImpl$LocalClient.executeInModelControllerCl(ModelControllerClientFactoryImpl.java:259)
              at org.jboss.as.controller@10.0.0.Beta6//org.jboss.as.controller.ModelControllerClientFactoryImpl$LocalClient.access$300(ModelControllerClientFactoryImpl.java:114)
              at org.jboss.as.controller@10.0.0.Beta6//org.jboss.as.controller.ModelControllerClientFactoryImpl$LocalClient$1.run(ModelControllerClientFactoryImpl.java:152)
              at org.jboss.as.controller@10.0.0.Beta6//org.jboss.as.controller.ModelControllerClientFactoryImpl$LocalClient$1.run(ModelControllerClientFactoryImpl.java:147)
              at org.wildfly.security.elytron-private@1.10.0.Final//org.wildfly.security.auth.server.SecurityIdentity.runAs(SecurityIdentity.java:289)
              at org.wildfly.security.elytron-private@1.10.0.Final//org.wildfly.security.auth.server.SecurityIdentity.runAs(SecurityIdentity.java:255)
              at org.jboss.as.controller@10.0.0.Beta6//org.jboss.as.controller.AccessAuditContext.doAs(AccessAuditContext.java:198)
              at org.jboss.as.controller@10.0.0.Beta6//org.jboss.as.controller.AccessAuditContext.doAs(AccessAuditContext.java:175)
              at org.jboss.as.controller@10.0.0.Beta6//org.jboss.as.controller.ModelControllerClientFactoryImpl$LocalClient.executeOperation(ModelControllerClientFactoryImpl.java:147)
              at org.jboss.as.controller@10.0.0.Beta6//org.jboss.as.controller.LocalModelControllerClient.execute(LocalModelControllerClient.java:54)
              at org.jboss.as.controller@10.0.0.Beta6//org.jboss.as.controller.LocalModelControllerClient.execute(LocalModelControllerClient.java:39)
              at org.wildfly.extension.microprofile.metrics-smallrye@18.0.0.Beta1//org.wildfly.extension.microprofile.metrics.MetricCollector.lambda$collectResourceMetrics0$0(MetricCollector.java:140)
              at org.wildfly.extension.microprofile.metrics-smallrye@18.0.0.Beta1//org.wildfly.extension.microprofile.metrics.PrometheusCollector.collect(PrometheusCollector.java:50)
              at io.prometheus.simpleclient//io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.findNextElement(CollectorRegistry.java:183)
              at io.prometheus.simpleclient//io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.(CollectorRegistry.java:147)
              at io.prometheus.simpleclient//io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.(CollectorRegistry.java:168)
              at io.prometheus.simpleclient//io.prometheus.client.CollectorRegistry.metricFamilySamples(CollectorRegistry.java:130)
              at org.wildfly.extension.microprofile.metrics-smallrye@18.0.0.Beta1//org.wildfly.extension.microprofile.metrics.MetricsContextService$1.lambda$handleRequest$0(MetricsContextService.java:101)
              at io.smallrye.metrics//io.smallrye.metrics.MetricsRequestHandler.handleRequest(MetricsRequestHandler.java:161)
              at io.smallrye.metrics//io.smallrye.metrics.MetricsRequestHandler.handleRequest(MetricsRequestHandler.java:73)
              at org.wildfly.extension.microprofile.metrics-smallrye@18.0.0.Beta1//org.wildfly.extension.microprofile.metrics.MetricsContextService$1.handleRequest(MetricsContextService.java:84)
              at org.jboss.as.domain-http-interface@10.0.0.Beta6//org.jboss.as.domain.http.server.security.RealmReadinessHandler.handleRequest(RealmReadinessHandler.java:51)
              at org.jboss.as.domain-http-interface@10.0.0.Beta6//org.jboss.as.domain.http.server.security.ServerErrorReadinessHandler.handleRequest(ServerErrorReadinessHandler.java:35)
              at io.undertow.core@2.0.26.Final//io.undertow.server.handlers.PathHandler.handleRequest(PathHandler.java:91)
              at io.undertow.core@2.0.26.Final//io.undertow.server.handlers.ChannelUpgradeHandler.handleRequest(ChannelUpgradeHandler.java:211)
              at io.undertow.core@2.0.26.Final//io.undertow.server.handlers.cache.CacheHandler.handleRequest(CacheHandler.java:92)
              at io.undertow.core@2.0.26.Final//io.undertow.server.handlers.error.SimpleErrorPageHandler.handleRequest(SimpleErrorPageHandler.java:78)
              at io.undertow.core@2.0.26.Final//io.undertow.server.handlers.CanonicalPathHandler.handleRequest(CanonicalPathHandler.java:49)
              at org.jboss.as.domain-http-interface@10.0.0.Beta6//org.jboss.as.domain.http.server.ManagementHttpRequestHandler.handleRequest(ManagementHttpRequestHandler.java:57)
              at org.jboss.as.domain-http-interface@10.0.0.Beta6//org.jboss.as.domain.http.server.cors.CorsHttpHandler.handleRequest(CorsHttpHandler.java:75)
              at org.jboss.as.domain-http-interface@10.0.0.Beta6//org.jboss.as.domain.http.server.ManagementHttpServer$UpgradeFixHandler.handleRequest(ManagementHttpServer.java:666)
              at io.undertow.core@2.0.26.Final//io.undertow.server.Connectors.executeRootHandler(Connectors.java:376)
              at io.undertow.core@2.0.26.Final//io.undertow.server.protocol.http.HttpReadListener.handleEventWithNoRunningRequest(HttpReadListener.java:255)
              at io.undertow.core@2.0.26.Final//io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:136)
              at io.undertow.core@2.0.26.Final//io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:59)
              at org.jboss.xnio@3.7.3.Final//org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
              at org.jboss.xnio@3.7.3.Final//org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66)
              at org.jboss.xnio.nio@3.7.3.Final//org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:89)
              at org.jboss.xnio.nio@3.7.3.Final//org.xnio.nio.WorkerThread.run(WorkerThread.java:591)
              
              
              08:48:54,940 ERROR [io.undertow.request] (management I/O-1) UT005071: Undertow request failed HttpServerExchange{ GET /metrics}: java.lang.IllegalStateException: WFLYMETRICS0003: Unable to read attribute second-level-cache-hit-count on [
                  ("subsystem" => "jpa"),
                  ("hibernate-persistence-unit" => "test-0.0.1-SNAPSHOT.war#my-persistence-unit"),
                  ("entity-cache" => "test.MyEntity")
              ]: "WFLYCTL0158: Operation handler failed: java.lang.NullPointerException".
              at org.wildfly.extension.microprofile.metrics-smallrye@18.0.0.Beta1//org.wildfly.extension.microprofile.metrics.MetricCollector.lambda$collectResourceMetrics0$0(MetricCollector.java:143)
              at org.wildfly.extension.microprofile.metrics-smallrye@18.0.0.Beta1//org.wildfly.extension.microprofile.metrics.PrometheusCollector.collect(PrometheusCollector.java:50)
              at io.prometheus.simpleclient//io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.findNextElement(CollectorRegistry.java:183)
              at io.prometheus.simpleclient//io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.(CollectorRegistry.java:147)
              at io.prometheus.simpleclient//io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.(CollectorRegistry.java:168)
              at io.prometheus.simpleclient//io.prometheus.client.CollectorRegistry.metricFamilySamples(CollectorRegistry.java:130)
              at org.wildfly.extension.microprofile.metrics-smallrye@18.0.0.Beta1//org.wildfly.extension.microprofile.metrics.MetricsContextService$1.lambda$handleRequest$0(MetricsContextService.java:101)
              at io.smallrye.metrics//io.smallrye.metrics.MetricsRequestHandler.handleRequest(MetricsRequestHandler.java:161)
              at io.smallrye.metrics//io.smallrye.metrics.MetricsRequestHandler.handleRequest(MetricsRequestHandler.java:73)
              at org.wildfly.extension.microprofile.metrics-smallrye@18.0.0.Beta1//org.wildfly.extension.microprofile.metrics.MetricsContextService$1.handleRequest(MetricsContextService.java:84)
              at org.jboss.as.domain-http-interface@10.0.0.Beta6//org.jboss.as.domain.http.server.security.RealmReadinessHandler.handleRequest(RealmReadinessHandler.java:51)
              at org.jboss.as.domain-http-interface@10.0.0.Beta6//org.jboss.as.domain.http.server.security.ServerErrorReadinessHandler.handleRequest(ServerErrorReadinessHandler.java:35)
              at io.undertow.core@2.0.26.Final//io.undertow.server.handlers.PathHandler.handleRequest(PathHandler.java:91)
              at io.undertow.core@2.0.26.Final//io.undertow.server.handlers.ChannelUpgradeHandler.handleRequest(ChannelUpgradeHandler.java:211)
              at io.undertow.core@2.0.26.Final//io.undertow.server.handlers.cache.CacheHandler.handleRequest(CacheHandler.java:92)
              at io.undertow.core@2.0.26.Final//io.undertow.server.handlers.error.SimpleErrorPageHandler.handleRequest(SimpleErrorPageHandler.java:78)
              at io.undertow.core@2.0.26.Final//io.undertow.server.handlers.CanonicalPathHandler.handleRequest(CanonicalPathHandler.java:49)
              at org.jboss.as.domain-http-interface@10.0.0.Beta6//org.jboss.as.domain.http.server.ManagementHttpRequestHandler.handleRequest(ManagementHttpRequestHandler.java:57)
              at org.jboss.as.domain-http-interface@10.0.0.Beta6//org.jboss.as.domain.http.server.cors.CorsHttpHandler.handleRequest(CorsHttpHandler.java:75)
              at org.jboss.as.domain-http-interface@10.0.0.Beta6//org.jboss.as.domain.http.server.ManagementHttpServer$UpgradeFixHandler.handleRequest(ManagementHttpServer.java:666)
              at io.undertow.core@2.0.26.Final//io.undertow.server.Connectors.executeRootHandler(Connectors.java:376)
              at io.undertow.core@2.0.26.Final//io.undertow.server.protocol.http.HttpReadListener.handleEventWithNoRunningRequest(HttpReadListener.java:255)
              at io.undertow.core@2.0.26.Final//io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:136)
              at io.undertow.core@2.0.26.Final//io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:59)
              at org.jboss.xnio@3.7.3.Final//org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
              at org.jboss.xnio@3.7.3.Final//org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66)
              at org.jboss.xnio.nio@3.7.3.Final//org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:89)
              at org.jboss.xnio.nio@3.7.3.Final//org.xnio.nio.WorkerThread.run(WorkerThread.java:591)
              • 4. Re: NullPointerException: org.wildfly.extension.microprofile.metrics.MetricCollector
                Scott Marlow Master

                I tried to reproduce following instructions above, only I'm using WildFly master branch to test, which is using Hibernate ORM 5.3.12.Final.  Could you try again with the WildFly nightly build (should also have ORM 5.3.12)

                 

                To attempt recreating, I used a simple war with persistence.xml:

                <?xml version="1.0" encoding="UTF-8"?>
                <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
                  <persistence-unit name="TEST_PU">
                    <jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>
                    <shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
                    <properties>
                    <property name="hibernate.enhancer.enableDirtyTracking" value="true"/>
                    <property name="hibernate.generate_statistics" value="true"/>
                    <property name="hibernate.cache.use_second_level_cache" value="true"/>
                <!--
                    <property name="hibernate.cache.use_query_cache" value="true"/>
                -->
                    </properties>
                  </persistence-unit>
                
                 <persistence-unit name="second_PU">
                    <jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>
                    <properties>
                    <property name="hibernate.enhancer.enableDirtyTracking" value="false"/>
                    <property name="hibernate.generate_statistics" value="false"/>
                    <property name="hibernate.cache.use_second_level_cache" value="true"/>
                <!-- 
                    <property name="hibernate.cache.use_query_cache" value="true"/>
                -->
                    </properties>
                  </persistence-unit>
                </persistence>
                

                 

                The metrics link shows results pasted to https://paste.fedoraproject.org/paste/XjpO4yC20K3~wB30uOfngw (no exceptions appeared in the WildFly console).

                 

                Thanks for reporting this!  It would be good to hear your results with ORM 5.3.12 (via nightly build link mentioned above), to verify that this bug is definitely fixed.

                 

                Scott

                • 5. Re: NullPointerException: org.wildfly.extension.microprofile.metrics.MetricCollector
                  Scott Marlow Master

                  FYI, you can also just use this link which I used, to download a recent build (I verified that ORM 5.3.12 is inside), just login as guest after clicking on https://ci.wildfly.org/repository/download/WF_Nightly/168928:id/wildfly-18.0.0.Final-SNAPSHOT.zip

                  • 6. Re: NullPointerException: org.wildfly.extension.microprofile.metrics.MetricCollector
                    Timon Zilles Newbie

                    With your provided version (18.0.0.Final-SNAPSHOT) the metrics are displayed/provided, but I still get some errors and warnings in the WildFly log - no matter whether my persistence.xml is pretty empty or whether I use your configuration which. In both scenarios the log looks pretty much the same:

                    https://paste.fedoraproject.org/paste/x5nFzj1dJH24lJsLv34brQ

                    https://paste.fedoraproject.org/paste/u8wmpJR3Ldz1W-D186~Lgg

                     

                    Hopefully there is no wrong or missing configuration in my project, but beside of an entity, a maven dependency to javax.persistence.javax.persistence-api:2.2, a simple web.xml and a persistence.xml there is nothing else.

                    • 7. Re: NullPointerException: org.wildfly.extension.microprofile.metrics.MetricCollector
                      Scott Marlow Master

                      Gail created a Hibernate tracking issue for the NPE, issue link is https://hibernate.atlassian.net/browse/HHH-13645.

                      Gail also created a pull request for the NPE as well, link is https://github.com/hibernate/hibernate-orm/pull/3049.

                       

                      Scott

                      1 of 1 people found this helpful