question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Combined Eureka and Configuration Server Returns XML

See original GitHub issue

I am migrating our Spring Cloud application from Angel.SR3 to Brixton.M3. Currently, we have combined the config server and the eureka server into a single app:

@SpringBootApplication
@EnableConfigServer
@EnableEurekaServer
public class DepbugApplication {

    public static void main(String[] args) {
        SpringApplication.run(DepbugApplication.class, args);
    }
}

I have set “spring.cloud.config.server.prefix” to “configuration”

In the Angel.SR3 release:

http://host:port/eureka/apps is returned as XML. http://host:port/configuration/appname/profile is returned as JSON

In the Brixton.M3 release:

http://host:port/eureka/apps is returned as XML. http://host:port/configuration/appname/profile is returned as XML

I believe this is because the eureka maven artifact has a runtime dependency on jackson-dataformat-xml which is then picked up by Spring Boot.

I am able to get the JSON version of the configuration by suffixing the URL with .json but JSON really should be the default/only format for the configuration end points.

In looking at the content negotiation in Spring MVC, it looks like this could be fixed by adding

produces={“application/json”} to the @RequestMapping for the various config server end points.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
pcornelissencommented, Feb 23, 2016

Found the culprit by accident 😃 It’s the cloud starter for eureka!

To fix the issue just use this:

      <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>com.fasterxml.jackson.dataformat</groupId>
                    <artifactId>jackson-dataformat-xml</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
1reaction
tkvangordercommented, Dec 17, 2015

Additional Information:

Chrome is sending the following in its Http Request Header:

Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8

I was able to work around this issue by extending the WebMvcConfigurerAdapter and telling the content negotiation to ignore the accept header and default to JSON:

@SpringBootApplication
@EnableConfigServer
@EnableEurekaServer
public class DepbugApplication extends WebMvcConfigurerAdapter {

    public static void main(String[] args) {
        SpringApplication.run(DepbugApplication.class, args);
    }

   @Override
   public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
     configurer.ignoreAcceptHeader(true).defaultContentType(MediaType.APPLICATION_JSON);
   }

}
Read more comments on GitHub >

github_iconTop Results From Across the Web

1. Service Discovery: Eureka Clients - Spring Cloud
Configuration is required to locate the Eureka server, as shown in the ... The Spring Cloud DiscoveryClient always returns a URI starting with...
Read more >
Spring Cloud: Service Discovery With Eureka - Medium
In a real world scenario, we may have multiple Eureka server nodes acting together as peer registries. When a Eureka server starts up,...
Read more >
Introduction to Spring Cloud Netflix - Eureka - Baeldung
In this tutorial, we'll introduce client-side service discovery via “Spring Cloud Netflix Eureka.” Client-side service discovery allows ...
Read more >
Spring Boot - Eureka Server - Tutorialspoint
Eureka Server is an application that holds the information about all client-service applications. Every Micro service will register into the Eureka server ......
Read more >
spring - Cannot connect to Eureka server. Exception: java.net ...
Update: If the above config does not works try with camelCase. eureka.client.registerWithEureka=false eureka.client.fetchRegistry= ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found