Microprofile counter CDI injection

66 views
Skip to first unread message

Jorge Oliveira

unread,
Jul 3, 2018, 12:52:11 PM7/3/18
to Payara Forum

Hello guys,

I am currently using Microprofile along with Payara Micro 5.182.
I just added Metrics to my application, unfortunately, when I try to inject any kind of counter the application just breaks. The error thrown is:
org.glassfish.deployment.common.DeploymentException: CDI deployment failure:WELD-001408: Unsatisfied dependencies for type Counter with qualifiers @Default
  at injection point
[UnbackedAnnotatedField] @Inject @Metric private com.jorge.testapp.api.TestApi.testCounter
  at com
.jorge.testapp.api.TestApi.testCounter(TestApi.java:0)
 
-- WELD-001408: Unsatisfied dependencies for type Counter with qualifiers @Default
  at injection point
[UnbackedAnnotatedField] @Inject @Metric private com.jorge.testapp.api.TestApi.testCounter
  at com
.jorge.testapp.api.TestApi.testCounter(TestApi.java:0)


Bellow is a sample of my code.
    @Inject
    @Metric(description = "Test metric")
    private Counter testCounter;
   
    @GET
    @Path("/v1")
    @Timed(name = "getTestTimer", description = "Duration of the getTest call")
    public Response getTest() {
        Response response;
       
        try {
            TestResponse testResponse = testService.doSomething();
            response = Response.ok(testResponse).build();
        } catch (final TestException e) {
            testCounter.inc();
            response = Response.status(Status.BAD_REQUEST).build();
        }
       
        return response;
    }

Does anyone knows why this is happening? It is strange because I've already used Metrics in other projects and everything went according to plan.
It seems that the application metrics are not working at all, since I have @Timed annotations in the code but even though the application runs with them they wont get traced.

Thank you.

Daniel Wamara

unread,
Jul 3, 2018, 3:58:12 PM7/3/18
to Payara Forum
There is a bug regarding metrics with 5.182 that has been fixed with 5.183. Yo just have to wait for the 5.183

Jorge Oliveira

unread,
Jul 17, 2018, 7:56:03 AM7/17/18
to Payara Forum
Hello again,

Just found out what the problem was:
I was disabling the classload delegation at the application level in order to fix an older version of payara. After adding delegation back everything went back to normal.

Thank you.
Reply all
Reply to author
Forward
0 new messages