REST application runs in Eclipse but not as an executable jar. NoClassDefFoundError: javax/xml/bind/annotation/XmlElement

Viewed 341

I have written REST resources using Jersey annotations. To make that work in Spring Boot I added a JerseyConfiguration class:

@Configuration
@ApplicationPath("/api")
public class JerseyConfiguration extends ResourceConfig {
    public JerseyConfiguration() {  }

    @PostConstruct
    public void setUp() {
        register(AdminController.class);
        register(AdminResource.class);
        register(GenericExceptionMapper.class);
    }
}

This works fine when running the application in Eclipse. When I create and run the jar-file I get the following error:

12:45:15.311 [main] ERROR o.s.boot.SpringApplication : Application startup failed org.springframework.context.ApplicationContextException: Unable to start embedded container;
nested exception is java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration': Bean instantiation via constructor failed;
nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration$$EnhancerBySpringCGLIB$$d46b8aee]: Constructor threw exception;
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'resourceConfigCustomizer' defined in class path resource [org/springframework/boot/autoconfigure/jersey/JerseyAutoCon   figuration$JacksonResourceConfigCustomizer.class]: Bean instantiation via factory method failed;
nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.autoconfigure.jersey.ResourceConfigCustomizer]: Factory method 'resourceConfigCustomizer' threw exception;
nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlElement

Can anybody tell me why this happens? As far as I know the javax/xml/bind/annotation is part of the Java 8 rt.jar

I am using Spring Boot 1.5.9.RELEASE, Java 8

1 Answers
Related