question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Build fails for @Provider exception mapper

See original GitHub issue

starting with 0.23.2 I get [ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:0.25.0:build (default) on project demo: Failed to build a runnable JAR: Failed to build a runner jar: Failed to augment application classes: Build failure: Build failed due to errors [ERROR] [error]: Build step io.quarkus.arc.deployment.ArcProcessor#registerBeans threw an exception: javax.enterprise.inject.spi.DefinitionException: Bean class com.demo.excmapper.IllegalArgumentExceptionMapper declares multiple scope type annotations: javax.enterprise.context.Dependent, javax.inject.Singleton

Steps to reproduce the behavior:

  1. Create sample hello project
  2. Add the class
import org.eclipse.microprofile.metrics.Counter;
import org.eclipse.microprofile.metrics.annotation.Metric;

import javax.inject.Inject;

import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;

@Provider
public class IllegalArgumentExceptionMapper implements ExceptionMapper<IllegalArgumentException> {
   
    @Inject
    @Metric(absolute = true, name = "error_count", description = "count", displayName = "error_count")
    private Counter counter;

    @Override
    public Response toResponse(IllegalArgumentException exception) {
        counter.inc();
        return Response.status(500).entity("illegal").build();
    }
}
  1. run mvn package getting-started.zip

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
jmartiskcommented, Oct 21, 2019

Oh, now I get it, so we’ll make the Metrics AnnotationsTransformer run after the one for Resteasy, and also when checking whether there is a scope present already, instead of doing BuiltinScope.isDeclaredOn(ctx.getTarget().asClass()), we will do BuiltinScope.isIn(ctx.getAnnotations()) (so it will see scopes added by other transformers), does that sound good?

I guess we could then discard the checks (in the Metrics transformer) whether the bean is a JAX-RS endpoint/provider, but for being extra safe I would maybe keep them… (?)

0reactions
gsmetcommented, Oct 21, 2019
Read more comments on GitHub >

github_iconTop Results From Across the Web

Defining exception mappers for resource exceptions and errors
Create a class that implements the javax.ws.rs.ext.ExceptionMapper class and annotate the class with the javax.ws.rs.ext.Provider annotation.
Read more >
ExceptionMapper provider not working with jersey
I read the documentation of Jersey and i undestand that i can register the exception mappers using @provider in the class. But the...
Read more >
Exception Handling | RESTful Java with JAX-RS 2 ... - dennis-xlc
The JAX-RS runtime throws this exception if a MessageBodyWriter fails or if there is an exception thrown from an ExceptionMapper. ServiceUnavailableException ...
Read more >
Chapter 27. Exception Handling - JBoss.org
ExceptionMappers are custom, application provided, components that can catch thrown application exceptions and write specific HTTP responses.
Read more >
Chapter 50. Handling Exceptions Red Hat Fuse 7.2
If an exception occurs while the exception mapper is building the Response object, the runtime will send a response with a status of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found