I'm trying to register my Java service with Eureka - with no luck. I have an existing code base that uses Spark-Java framework, so that 'add only 2 lines of Spring annotations and voila!' examples unfortunately are not helpful for me.
I read the Eureka Configuration documentation, created a eureka-conf directory and put the following two files in eureka-conf:
I added the eureka_conf path to my $CLASSPATH variable with export CLASSPATH=.:${CLASSPATH}:${EUREKA_CONF}/eureka-client.properties:${EUREKA_CONF}/eureka-service.properties
I copy-pasted the content of the property files from here. So, they look like this:
#eureka-client.properties
eureka.registration.enabled=false
eureka.preferSameZone=true
eureka.shouldUseDns=false
eureka.serviceUrl.default=http://localhost:8080/eureka/v2/
eureka.decoderName=JacksonJson
#eureka-service.properties
eureka.region=us-west-1
eureka.name=qb-acm
eureka.vipAddress=mysampleservice.mydomain.net
eureka.port=8001
eureka.preferSameZone=true
eureka.shouldUseDns=false
eureka.serviceUrl.default=http://localhost:8080/eureka/v2/
You can see, I changed the eureka.name and eureka.region to see in the logs if the properties are being found or not. They are not found.
When I start my service I see the com.netflix.discovery.internal.util.Archaius1Utils
throws the following warning:
Cannot find the properties specified : eureka-client. This may be okay if there are other environment specific properties or the configuration is installed with a different mechanism.
Followed by this: INFO com.netflix.discovery.DiscoveryClient - Initializing Eureka in region us-east-1
.
I've created an example Eureka Server and Client (with Spring) just to do an example and the Spring client is registered. Now, I'm trying to have my non-Spring Java service register with the local Eureka server. My end goal is to set this service to register and send heart beats to our remote Eureka server which is being hosted on Pivotal.
Other errors might be useful to the reader:
[main] ERROR com.netflix.discovery.shared.resolver.aws.ConfigClusterResolver - Cannot resolve to any endpoints from provided configuration: {defaultZone=[]}
[main] ERROR com.netflix.discovery.shared.transport.EurekaHttpClients - Initial resolution of Eureka server endpoints failed. Check ConfigClusterResolver logs for more info
So, my questions are:
What am I doing wrong setting the properties?
I see in many examples they have an application.yml
or manifest.yml
file. What is the .yaml file
for in Eureka configuration? Is it an alternative to the property
files?
edit: I found this answer explains the yaml files. Application.yml is used by Spring boot and Manifest.yml is used by cloud foundry CLI.
**edit: I found out, with trial and error, on local this is set to http://localhost:yourport and for PCF it should be the application name. Neither localhost
nor service-name
corresponds to a physical network interface. Oh well, I finally learned what a virtual ip is **
Let me know if more information needed. Thanks in advance for any help.
It seems, that your config files are not found during startup. The eureka configuration files must be on the classpath. Sometimes they are not packaged to the jar file. Be sure to have the files in your jar
(try jar xf <your-jar-file>
to analyze the content of your jar.
Are you building with maven? Then add a resource/include block in the build section of your pom-File to ensure the inclusion of the config files.
Some of the eureka properties can be set in the application.yml files which is the same as applicaiton.properties except for the format you are writing your configurations. I am not sure if there is a eureka-client.properties equivalent for yaml. First get the *.properties running, then try if it understands yaml.