I have my Eureka server (registry) upend running. However, it shows that it is registered, but not available.
I'm going off of the tutorial found here which says to turn off logging and prevent the server from registering itself.
Edit: have confirmed the problem is not with the server. it can now register itself. additionally, I used the client from this demo (in a wholly separate project) which registers itself with my server.
My client now does not run. Here are the dependencies from the pom file:
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>org.nt.springframework.data</groupId>
<artifactId>nt-spring-data-marklogic</artifactId>
<version>1.1.8.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-commons</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream</artifactId>
<version>2.0.0.RC3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-stream-binder-kafka -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-kafka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
<version>1.11</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.11</version>
</dependency>
Here is the client main file:
package com.example;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.marklogic.repository.config.EnableMarkLogicRepositories;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@EnableDiscoveryClient
@SpringBootApplication
@EnableMarkLogicRepositories("com.example.repository")
@ComponentScan({"com.id.example"})
@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
public class ClientApp {
public static void main(String[] args) {
System.out.println("Starting app...");
SpringApplication.run(ClientApp.class, args);
}
}
Here is the error:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.10.RELEASE)
[2018-04-23 16:27:44.811] - 91242 INFO [main] --- org.apache.catalina.core.StandardService: Starting service [Tomcat]
[2018-04-23 16:27:44.816] - 91242 INFO [main] --- org.apache.catalina.core.StandardEngine: Starting Servlet Engine: Apache Tomcat/8.5.27
[2018-04-23 16:27:45.163] - 91242 INFO [localhost-startStop-1] --- org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/]: Initializing Spring embedded WebApplicationContext
[2018-04-23 16:28:04.271] - 91242 INFO [main] --- org.apache.catalina.core.StandardService: Stopping service [Tomcat]
Exception in thread "main" org.springframework.context.ApplicationContextException: Failed to start bean 'eurekaAutoServiceRegistration'; nested exception is java.lang.NullPointerException
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178)
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:50)
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:348)
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:151)
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:114)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:880)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:144)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
at com.ibm.tsd.TradeServiceDemoApplication.main(TradeServiceDemoApplication.java:21)
Caused by: java.lang.NullPointerException
at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaServiceRegistry.maybeInitializeClient(EurekaServiceRegistry.java:56)
at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaServiceRegistry.register(EurekaServiceRegistry.java:37)
at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaAutoServiceRegistration.start(EurekaAutoServiceRegistration.java:80)
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:175)
... 14 more
Any help would be appreciated!
You have to separate your "Server-application" (let's call it EurekaServerApplication
) from your "Client-application" (let's call it EurekaClientApplication):
In your Server-application add the eureka-server
dependency:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
Your Server-application must be decorated with the @EnableEurekaServer
annotation
@SpringBootApplication
@EnableEurekaServer
public class EurekaServerApplication {..}
Add the 'eureka-client' dependency to the pom.xml
of your Client-application :
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
In your client application.properties
or application.yml
you must have:
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
The port value 8761 must be of course the same as the one in your Server-application:
server:
port: ${PORT:8761}
Note: You don't need to decorate the ClientEurekaApplication with the @EnableEurekaClient
or @EnableDiscoveryClient
annotation to let your client be discovered from/by the ServerEurekaApplication.
I am using configurations for clients like this ( yml
):
server:
port: 8080
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
spring:
application:
name: clientname
You can keep using your application.properties
instead of yml
. Simply add spring.application.name=applicationname
Please check if you forgot to set an applicationname
. Also make sure your discovery-service
is up before you start your client
.
To see your eureka-service
you would need to go to http://localhost:8761
. To access your client
use http://localhost:8761/clientname
I have this error in one project I have to upgrade and I fix it eliminating or deleting some library dependency in maven. It caused problems when picking the right library for something related to Jackson 5 or Jersey.
See your dependency hierarchy and start playing or ordering things.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.