-
Notifications
You must be signed in to change notification settings - Fork 41.7k
Closed
Description
I have an Gradle project in which the root project is just a container for the submodules, and provides some common config. The submodules are:
- domain (package: xxx.domain)
- service (depends on domain, package: xxx.service)
- rest (depends on service, package xxx.rest) - the project using spring boot, with spring-boot-starter-jersey; the @SpringApplication annotation is on xxx.Application, and all endpoints are in xxx.rest.
Jersey config is defined the following way:
@Bean
public ResourceConfig endpointConfig() {
ResourceConfig config = new ResourceConfig();
config.packages(true, Application.class.getPackage().getName()); // 'xxx', recursive
return config;
}
This works fine when running from the IDE (IDEA 14.1) and with 'gradle bootRun', but fails when using 'java -jar' on the repackaged jar with the following error (Indentation from me to make it a bit more readable):
Caused by: java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration': Injection of autowired dependencies failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.glassfish.jersey.server.ResourceConfig org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration.config; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'endpointConfig' defined in xxx.Application: Bean instantiation via factory method failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.glassfish.jersey.server.ResourceConfig]: Factory method 'endpointConfig' threw exception; nested exception is
org.glassfish.jersey.server.internal.scanning.ResourceFinderException: java.io.FileNotFoundException: /Users/wujek/Development/IdeaProjects/xxx/rest/build/libs/xxx.rest-0.1.jar!/lib/xxx.service-0.1.jar (No such file or directory)
Apparently, it attempts to scan the packages from the contained jars but it fails to do so.
I'm not sure whether this is a Jersey issue or a limitation of the executable jar format, which I somehow violate, or a combination of both. I guess it works from the IDE and with bootRun as the run is performed on exploded resources, not packed in jars.
Metadata
Metadata
Assignees
Labels
No labels