Spring-cloud-netflix: The home page of eureka-server is shown as XML format

Created on 2 May 2017  Â·  23Comments  Â·  Source: spring-cloud/spring-cloud-netflix

Hello eldest brother,

I met a strange question, when I visit home page(http://127.0.0.1:1111/), it's not like HTML page, but this:

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<com.netflix.eureka.util.StatusInfo>
<generalStats>
<current-memory-usage>440mb (86%)</current-memory-usage>
<num-of-cpus>4</num-of-cpus>
<total-avail-memory>507mb</total-avail-memory>
<environment>test</environment>
<server-uptime>00:04</server-uptime>
</generalStats>
<applicationStats>
<unavailable-replicas>http://localhost:8761/eureka/,</unavailable-replicas>
<available-replicas/>
<registered-replicas>http://localhost:8761/eureka/</registered-replicas>
</applicationStats>
<instanceInfo>
<instanceId>WCMIS208:SmartDataStack-Robot:1111</instanceId>
<hostName>WCMIS208</hostName>
<app>SMARTDATASTACK-ROBOT</app>
<ipAddr>10.16.72.21</ipAddr>
<status>UP</status>
<overriddenstatus>UNKNOWN</overriddenstatus>
<port enabled="true">1111</port>
<securePort enabled="false">443</securePort>
<countryId>1</countryId>
<dataCenterInfo class="com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo">
<name>MyOwn</name>
</dataCenterInfo>
<leaseInfo>
<renewalIntervalInSecs>30</renewalIntervalInSecs>
<durationInSecs>90</durationInSecs>
<registrationTimestamp>0</registrationTimestamp>
<lastRenewalTimestamp>0</lastRenewalTimestamp>
<evictionTimestamp>0</evictionTimestamp>
<serviceUpTimestamp>0</serviceUpTimestamp>
</leaseInfo>
<metadata class="java.util.Collections$EmptyMap"/>
<homePageUrl>http://WCMIS208:1111/</homePageUrl>
<statusPageUrl>http://WCMIS208:1111/info</statusPageUrl>
<healthCheckUrl>http://WCMIS208:1111/health</healthCheckUrl>
<vipAddress>SmartDataStack-Robot</vipAddress>
<secureVipAddress>SmartDataStack-Robot</secureVipAddress>
<isCoordinatingDiscoveryServer>false</isCoordinatingDiscoveryServer>
<lastUpdatedTimestamp>1493688759999</lastUpdatedTimestamp>
<lastDirtyTimestamp>1493688760705</lastDirtyTimestamp>
</instanceInfo>
</com.netflix.eureka.util.StatusInfo>

This is a xml page? and my pom.xml is this:

<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.newegg.dba</groupId>
  <artifactId>smartDataStack-robot</artifactId>
  <version>0.0.1-SNAPSHOT</version>

  <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-parent -->
  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.2.RELEASE</version>
  </parent>

  <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>

    <dependency>
      <groupId>commons-dbutils</groupId>
      <artifactId>commons-dbutils</artifactId>
      <version>1.6</version>
    </dependency>
  </dependencies>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-dependencies</artifactId>
        <version>Dalston.RELEASE</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
</project>

And application.properties is this:

spring.application.name=SmartDataStack-Robot

server.port=1111

eureka.client.registerWithEureka=false
eureka.client.fetchRegistry=false
eureka.client.waitTimeInMsWhenSyncEmpty=0

And Application class is this:

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;


@EnableEurekaServer
@SpringBootApplication
public class MainBootApplication {

    public static void main(String[] args) { 
        new SpringApplicationBuilder(MainBootApplication.class).web(true).run(args);
    }

}

Can you help me? I very very want to an HTML page, Thank you very very much

Most helpful comment

@hkharikrishnan857 Are you starting directly in the IDE? This in Eclipse Debug will happen, Because it not found 'eureka/status.ftl' and others resources 'static/eureka/*' in ../classes

You can run using way of the jar package, or copy 'static/*' and 'templates/*' to your project's resources floder from the 'spring-cloud-netflix-eureka-server-*.RELEASE.jar' if you must be run using way of Eclipse(IDE?)

And after compiling you can see this directory structure:

-- classes
  -- static
    -- eureka
      -- css
      ...
  -- templates
    -- eureka
      -- status.ftl
      ...

But the direct use of jar package to run, there is no such catalog and there is no such problem, So what's the way you run it?

All 23 comments

Same problem happens on my friend's environment.
It semms that some dependencies is missing .Try command below:

mvn clean install -U

UNTIL you make this build success.

@eacdy I tried, still not OK, I find it's Content-Type of Response Headers is 'application/xml', strange.. and Thank you 💯

If you could provide the sample app as either a zip or in a git repo we can try and reproduce that problem. But I agree with @eacdy it sounds like it might be something in your local environment causing an issue.

@ryanjbaxter I can't upload files now, because I am in the company(company have relevant regulation), after I go home will provide the same app, and thank you very mach 💯

@eacdy @ryanjbaxter Maybe you are right, Before I've been run in Eclipse, Just now I use the Jar package to run, the page can display properly, Although in Eclipse run will still have question, but is there a way can display properly still makes me feel happy, Thank you very very mach for your answer,fortunately suffer

i can't get the eureka status page instead i got xml file only


xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0

<groupId>com.example</groupId>
<artifactId>eureka-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.2.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.8</java.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>Camden.SR5</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>

application.properties

spring.application.name=eureka-service
server.port=8761

eureka.client.serviceUrl.defaultZone =http://localhost:8761/eureka/

eureka.instance.hostname=localhost

eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
#
logging.level.com.netflix.eureka=OFF
logging.level.com.netflix.discovery=OFF

EurekaServiceApplication.java

package com.eureka.server;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

@EnableEurekaServer
@SpringBootApplication
@EnableDiscoveryClient
public class EurekaServiceApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaServiceApplication.class, args);
}
}

@hkharikrishnan857 most likely an issue in your environment and not a problem in Spring Cloud

@hkharikrishnan857 Are you starting directly in the IDE? This in Eclipse Debug will happen, Because it not found 'eureka/status.ftl' and others resources 'static/eureka/*' in ../classes

You can run using way of the jar package, or copy 'static/*' and 'templates/*' to your project's resources floder from the 'spring-cloud-netflix-eureka-server-*.RELEASE.jar' if you must be run using way of Eclipse(IDE?)

And after compiling you can see this directory structure:

-- classes
  -- static
    -- eureka
      -- css
      ...
  -- templates
    -- eureka
      -- status.ftl
      ...

But the direct use of jar package to run, there is no such catalog and there is no such problem, So what's the way you run it?

@ryanjbaxter , I have been following this issue since last couple of hours and could not get it solved. Further, I would like to share my observations:

The Eureka server dashboard renders fine when running from Linux box (from eclipse or uber jar) but does not looks fine(as in, it shows xml in browser, be it chrome or firefox) when running on Windows box.

Could it be a OS platform issue ? And if it is, then is it something to do with Spring Cloud module ?

Sharing some details:

Spring boot version: 1.5.2.RELEASE
Spring Cloud Version: Dalston.RELEASE
Eclipse version - Mars( on windows box)
Eclipse version - Mars ( on Linux box)

Regarding code, it's very simple project with only single class annotated with @SpringBootApplication and @EnableEurekaServer and off-course pom.xml with dependencies as described above

Will appreciate if you could look into it and should you require more information, kindly revert.

Regards

I'd think it may have to do with the version of the jvm as well.

Just checked the version on both boxes:

Linux : java version 1.8.0_131
Windows: java version 1.8.0_121
Both from Oracle.

I dont think anyone on the team has a windows box to try this out. I would imagine if everyone who was using windows was seeing this we would see a lot of issues about this...

Thanks @ryanjbaxter for your kind response. Yes, I agree with your observation. The problem was with following dependency as it got corrupted. So I just have to remove it from my local maven repository and issue a force update.

freemarker-2.3.25-incubating.jar

It worked after this.

Thanks.

I think it happens if you use bootRun to run instead of executing the JAR directly.

@kentTanL
I am having this same problem. I took the project found at "https://github.com/spring-cloud-samples/eureka" and update the project to use spring-boot 1.5.8. After that, it fails to load the Dashboard. I pulled the /static and /template directories and put it in the main/resources, but the same problem occurs.

@cbriarnold you changed spring-boot version to 1.5.8, and are you change spring-cloud version?

reference link: http://projects.spring.io/spring-cloud/

@kentTanL Yes.
`` <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Dalston.SR4</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>

Can you try to package into a JAR package and run it? I can't reproduce your problem locally, sorry

I encountered the same problem, and it bothered me all day.
windows jdk: jdk1.8.0_101
Eclipse: Neon Release Candidate 3 (4.6.0RC3)
Maven: apache-maven-3.3.3
Spring boot: 1.5.8.RELEASE
spring-cloud.version: Dalston.SR4

If I run java -jar by maven installed in command line, it is normal that visit home page http://localhost:8761.
who can tell me why?

Your ide classpath isn't the same as when running in the ide

it`s ok, I did nothing but execute clean and build project。
thanks

@armulchandani You save my day! It is the freemarker's jar caused the problem. I remove the maven repository of freemarker and update the maven project, then the eureka UI becomes all right. Thank you!

find maven repo and clean freemaker-XX.jar files ;then maven update

Was this page helpful?
0 / 5 - 0 ratings