Spring Boot Application - Running jar file gives ResourceFinderException error

Viewed 9

Created a jar file for a spring boot multimodule application and ran the jar file using java -jar command. While starting the application, it gives ResourceFinderException. When I analyzed it, the issue is happening because in my ResourceConfig file, i have used the package for my api end points. If I use register(service.class), the application starts fine. Any suggestion how can I provide the package instead of using register? The reason I want to use package is because I have lots of services inside multiple packages and the code looks very ugly if i use register for all the services. The ResourceConfig file looks like below.

public class AppResourceConfig extends ResourceConfig {
    public AppResourceConfig {}{
      super();
    property("jersery.config.beanValidation.enableOutputValidationErrorEntity.server");
    **packages("com.api");**
    register(GsonProvider.class);
    register(RequestContextFilter.class);
    register(NotFoundExceptionMapper.class);
    register(DefaultExceptionMapper.class);
    }
    
}

Here the issue is with highlighted line: packages("com.api") If I comment out this code application will be up. Otherwise it is giving org.glassfish.jersey.server.internal.scanning.ResourceFinderException: java.io.FileNotFoundException: api-01.03.00.04-snapshot.jar (No such file or direcotry)

Note: api-01.03.00.04-snapshot.jar is the jar file for one of the module in a project

0 Answers
Related