I am trying to set up a Zuul gateway with a Eureka Server and several clients.
So far, I have created the Gateway and and initial Client without problems, but for some reason i keep getting an error when I try to start the registry.
As far as I can tell, the problem has to do with loading the configuration, with the root being that the class com/sun/jersey/core/util/FeaturesAndProperties
is not found.
I have tried defining the Jersey components explicitly, but no matter how I set up the pom (jersey before the spring imports, jersey after the imports, different versions) I get the same issue.
I have also tried different release trains, based on this page http://projects.spring.io/spring-cloud/ and read up on the different dependencies.
I have also tried following the guide illustrated here http://www.baeldung.com/spring-cloud-netflix-eureka (I am aware that the version is different, I have adjusted the values to several other release trains)
At this time, the jersey imports are present in the Maen dependencies section, with the pom.xml shown below. (see screenshot)
I am a little baffled as to why i can't get this to run. any help would be appreciated, or a point to a guide with more details.
it is worth mentioning that my application.yml is deduced from my readings, and i get the same error with a blank application.yml (or application.properties, which i have deleted)
Repository at https://github.com/JoSSte/MyEurekaRegistry
This is the error line as defined in the Console:
2018-01-07 13:05:59.334 ERROR 5708 --- [ost-startStop-1] o.s.b.c.embedded.tomcat.TomcatStarter :
Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'jerseyFilterRegistration' defined in class path resource [org/springframework/cloud/netflix/eureka/server/EurekaServerAutoConfiguration.class]: Unsatisfied dependency expressed through method 'jerseyFilterRegistration' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jerseyApplication' defined in class path resource [org/springframework/cloud/netflix/eureka/server/EurekaServerAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.ws.rs.core.Application]: Factory method 'jerseyApplication' threw exception; nested exception is java.lang.NoClassDefFoundError: com/sun/jersey/core/util/FeaturesAndProperties
MyRegistryApplication.java
package com.example.backend;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
@EnableEurekaServer
public class MyRegistryApplication {
public static void main(String[] args) {
SpringApplication.run(MyRegistryApplication.class, args);
}
}
application.yml
server:
port: 8761
eureka:
instance:
hostname: localhost
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
server:
waitTimeInMsWhenSyncEmpty: 0
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>MyRegistry</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>MyRegistry</name>
<description>My Gateway</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Edgware.RELEASE</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
EDIT # 1:
based on this question, How to solve "Plugin execution not covered by lifecycle configuration" for Spring Data Maven Builds I Decided to list my dependencies (mvn dependency:list | grep jersey
) and see if there are conflicting versions of Jersey in my dependencies:
[INFO] com.sun.jersey:jersey-core:jar:1.19.1:compile
[INFO] com.sun.jersey:jersey-server:jar:1.19.1:compile
[INFO] com.sun.jersey:jersey-servlet:jar:1.19.1:compile
[INFO] com.sun.jersey.contribs:jersey-apache-client4:jar:1.19.1:runtime
[INFO] com.sun.jersey:jersey-client:jar:1.19.1:runtime
As this list indicates, I have the same version of Jersey. Besides that, I have no jax-rs, nor any glassfish in my dependencies