Search code examples
jerseyjax-rsmicroprofilehelidon

Classes defined in a library are not being picked up by jersey in Helidon


I am currently using helidon 4.0.5

I have a library com.example.library where I have some classes for example

@Provider
public class LoggingRequestFilter implements ContainerRequestFilter{
    
    
    @Override
    public void filter(ContainerRequestContext requestContext) throws IOException {
        System.out.print("FILTERER");
        
    }

}

I am trying to import this library in the helidon starter application but the filter is not being picked up by jax-rs.

If I write the same filter inside the helidon starter application it works fine.


Solution

  • Add beans.xml in your dependency jar libary so it will process the @Provider annotation. CDI won’t process annotations if there is no beans.xml in your dependency jar. Helidon use CDI to pick providers up, so the jar containing the filter must be a bean jar (and hence it must have beans.xml).