Adding Jersey Configuration disables register view controller

764 Views Asked by At

i am using springboot 1.5.2 and i am using jersey and jsf

i have mapping for default view / as follows:

@Bean
    public WebMvcConfigurerAdapter defaultView() {
        return new WebMvcConfigurerAdapter() {
            @Override
            public void addViewControllers(ViewControllerRegistry registry) {
                registry.addViewController("/").setViewName("forward:/faces/public/login.xhtml");
                registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
                super.addViewControllers(registry);
            }
        };
    }

before i added jersey configuration, it was working fine, and after i added the following jersey configuration it stopped working:

@Configuration
public class JerseyConfig extends ResourceConfig {
    public JerseyConfig() {
        register(MyService.class);
    }
}

when i remove the JerSeyConfig class, the mapping works fine, but when i add it, the mapping stops working, please advise how to make them both working together fine.

1

There are 1 best solutions below

0
ootero On

Could you try:

  • Annotate JerseyConfig with @Component instead of @Configuration and make sure package is being scanned via @ComponentScan in main class.

  • Make sure Spring MVC dispatcher servlet is mapped to a path different than Jersey servlet's, for instance:

    # Spring MVC dispatcher servlet path. Needs to be different than Jersey's to enable/disable Actuator endpoints access (/info, /health, ...)

    server.servlet-path: /

    # Jersey dispatcher servlet

    spring.jersey.application-path: /api

More details could be found at my blog post: Microservices using Spring Boot, Jersey, Swagger and Docker