Hi, I'm trying to deploy my eureka server on JBoss Wildfly 18 in a Docker container but the dashboard doesn't show. If I try with jar and tomcat embedded all goes well but not in JBoss Wildfly. I deploy my war with name eureka.war and it goes well, Wildfly say the deployment is ok and give it the path /eureka but when I call the url http://127.0.0.1:8761/eureka nothing happen. I have tried changing the port, various urls, but nothing.
My application.properties is
server.port = 8761
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
eureka.instance.hostname = localhost
My demoApplication:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
@EnableEurekaServer
public class DemoApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(DemoApplication.class);
}
}
My 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<packaging>war</packaging>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-netflix-eureka-server -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
<version>2.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>15.0</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-parent</artifactId>
<version>Hoxton.RELEASE</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>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Dependencies>jdk.unsupported</Dependencies>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
And in JBoss docker my Dockerfile:
FROM jboss/wildfly:18.0.1.Final
COPY docker/jboss/war/eureka.war /opt/jboss/wildfly/standalone/deployments/eureka.war
USER jboss
RUN /opt/jboss/wildfly/bin/add-user.sh admin Admin#70365 --silent
CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0"]
and my docker-compose.yml:
version: '3.5'
services:
jboss:
build:
context: .
dockerfile: ./docker/jboss/Dockerfile
container_name: jboss
ports:
- 8080:8080
- 8761:8761
- 9990:9990
Someone know how to resolve the problem?
Thanks
Comment From: spencergibb
did you try to access /eureka/eureka since a war will add a context?
Comment From: brunopicci
Hi, thx for the response. Yes, I've tried all. Now I can see the dashboard, I've followed the @andreasevers message, this: https://github.com/spring-cloud/spring-cloud-netflix/issues/205
But the problem remain. I see the dashboard (and in the dashboard seems all ok) but Eureka seems not to work. The Services can't send the heartbeat because Eureka server return not Found and all eureka server api rest services seems not active.
I tried to call them from postman but they respond with 404.
If I use the flat jar and not JBoss, it works and I can call the api rest correctly.
The eureka api rest that I call are (without the v2 in the endpoint): https://github.com/Netflix/eureka/wiki/Eureka-REST-operations
Do you have some suggest, please? Thx
Comment From: spencergibb
What url can you view the dashboard?
Comment From: brunopicci
The registry respond to this url: http://127.0.0.1:8761/peav-api-registry/ peav-api-registry is the context name under jboss eap 7.1 This is the page: link
Comment From: spencergibb
Did you change the context of all the services to http://127.0.0.1:8761/peav-api-registry/eureka?
Comment From: brunopicci
do you mean the services exposed by the register? That should happen automatically. My demoApplication now is: @SpringBootApplication @EnableEurekaServer @Configuration @EnableAutoConfiguration public class PeavApiRegistryApplication extends SpringBootServletInitializer {
private static final String DEFAULT_TEMPLATE_LOADER_PATH = "classpath:/templates/";
private static final String DEFAULT_CHARSET = "UTF-8";
public static void main(String[] args) {
SpringApplication.run(PeavApiRegistryApplication.class, args);
}
@SuppressWarnings("unused")
@Autowired
private FilterRegistrationBean<ServletContainer> jersey;
@Bean
public FilterRegistrationBean<ServletContainer> jersey() {
FilterRegistrationBean<ServletContainer> bean = new FilterRegistrationBean<ServletContainer>();
bean.setFilter(new ServletContainer());
bean.setOrder(Ordered.LOWEST_PRECEDENCE);
bean.addInitParameter("com.sun.jersey.config.property.WebPageContentRegex",
EurekaServerConfigBean.PREFIX + "/(fonts|images|css|js)/.*");
bean.addInitParameter("com.sun.jersey.config.property.resourceConfigClass", JerseyResourceConfig.class.getName());
bean.setUrlPatterns(Lists.newArrayList(EurekaServerConfigBean.PREFIX
+ "/*"));
return bean;
}
/**
* Overrides Spring Boot's {@link FreeMarkerAutoConfiguration} to prefer
* using a {@link SpringTemplateLoader} instead of the file system. This
* corrects an issue where Spring Boot may use an empty 'templates' file
* resource to resolve templates instead of the packaged Eureka classpath
* templates.
*
* @return FreeMarker configuration
*/
@Bean
public FreeMarkerConfigurer freeMarkerConfigurer() {
FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
configurer.setTemplateLoaderPaths(DEFAULT_TEMPLATE_LOADER_PATH);
configurer.setDefaultEncoding(DEFAULT_CHARSET);
configurer.setPreferFileSystemAccess(false);
return configurer;
}
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(PeavApiRegistryApplication.class);
}
}
i call this endpoint to call the eureka services: http://localhost:8761/peav-api-registry/eureka
For the apps: http://localhost:8761/peav-api-registry/eureka/apps
Comment From: brunopicci
This is the project skeleton: https://we.tl/t-eJyUVP8edw
Comment From: spencergibb
Ok. I don't know what the current problem is.
Comment From: brunopicci
Ok, but the question is: "Eureka Registry is compatible with JBOSS 7.1 or not"? Because if it is compatible I can continue to search a solution, if it is not compatible I stop to search. Have you ever managed to make it work?
Thanks
Comment From: spencergibb
That would be a question for https://github.com/Netflix/eureka/