FAQ Database Discussion Community


How to create a custom Spring PropertySource that depends on a Spring Bean

java,spring,spring-boot,spring-cloud,netflix-zuul
I'm attempting to use the spring-cloud stack for a project that would use Zuul. In my organization we have a custom configuration stack that is xml-based and does property composition and hierarchical overrides. Because of the way this configuration is handled, I've struggled to create a PropertySource for it. My...

How to avoid configserver.yml from appearing in Spring Cloud config server /env resource output?

spring-cloud
I was able to define a Spring Boot project and include the following dependency in my pom: <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-config-server</artifactId> <version>1.0.0.RELEASE</version> </dependency> I then added the @EnableConfigServer annotation on my class. So far so good. I then created a bootstrap.yml file to point to my git repository. The application runs...

How can I get the Discovery Client working when using spring-cloud together with netflix Eureka?

java,spring,spring-cloud,netflix-eureka
I'm trying to make a basic project using spring cloud with the netflix addons such as Hystrix, Eureka and Ribbon to learn how this works. The project I'm trying to make is a simple message server that will keep messages. And a message-client that will just ask the server for...

Spring Cloud Config Globals

java,spring,spring-boot,spring-cloud
I have a scenario where I need to set some properties globally for several applications. Is there support for default or global configs in spring cloud config? Example: #default.properties setting=global_setting #myapp.properties something_else=app_setting #anotherapp.properties prop=different_app_setting Here I would want for "myapp" to have setting set. Any help would be greatly appreciated....

Spring Cloud Bus

spring-cloud
I see that currently Spring Cloud Bus uses rabbit. Is there the possibility that it might be ported to kafka (http://kafka.apache.org) at some point?

Installing Spring Cloud Services for Cloudfoundry without OpsManager

cloudfoundry,spring-cloud
I've installed cloudfoundry on my local machine as described here and now I'd like to install Spring Cloud Services as well. However I don't know where to find OpsManager and I doubt if it is deployed at all. So the question is - is it possible to install Spring Cloud...

Override spring-boot EurekaInstanceConfigBean

java,spring,spring-cloud
I am building a dockerized spring-cloud based microservice that registers with eureka. Part of the registration process is asking the host for the port mapped to the container so docker can choose a free host port for the containerized service. I have a host based service the dockerized service can...

Accessing CloudFoundry user-provided services using Spring Cloud connectors

java,spring,spring-mvc,cloudfoundry,spring-cloud
I'm trying to use Spring Cloud to consume a generic REST service from a Cloud Foundry app. This service is created using Spring Boot, as follows: package com.something; @RestController public class DemoServiceController { @RequestMapping("/sayHi") public String sayHi() { return "Hello!"; } } This works fine - I can access http://www.example.com/srv/demo/sayHi...

Spring Cloud Config - How do we see this being used?

spring,spring-boot,spring-cloud
I have been playing with Spring Cloud Config and like many of the ideas I see there. I would like to better understand how its creators intended on it being used though. Lets say that I have several services that support a larger API. Because these services are independent from...

Spring Cloud FeignClient decoding application/hal+json Resource return type spring-data-rest,spring-cloud,spring-hateoas
I'm developing a REST API using Spring Cloud, Spring Data JPA, Spring Data Rest and Spring Boot. The server implementation generates the various data items correctly, according to the HAL spec and so forth. It generates the HAL+JSON as follows: { "lastModifiedBy" : "unknown", "lastModifiedOn" : "2015-06-04T12:19:45.249688", "id" : 2,...

How do you create custom zuul filters in spring cloud

spring-cloud,netflix-zuul
I want to write some of my own custom zuul filters for a spring cloud microservice i am writing. Once i have the filter written how do I integrate it so the underlying netflix zuul framework can take advantage of it.

Using Eureka with Ribbon doesn't send custom header

spring-cloud,netflix,netflix-eureka
Current project uses spring-cloud-starter-eureka version 1.0.0.RELEASE. I am using Ribbon to connect to some other services and require a custom header. @Autowired private RestTemplate restTemplate; . . . ResponseEntity result = this.restTemplate.exchange("https://FooServices/foos/daily", HttpMethod.GET, new HttpEntity(getSpecialHeaders()), FooView[].class, new Object[0]); The code works fine for Spring Cloud version 1.0.0. However, when I...

Remapping the Eureka context

spring-cloud
Out of the box, eureka provides information at "/" as in "http://localhost:8761/". Is there an easy way to move change this context? Say for example, I want to have this"http://localhost:8762/services" instead?...

Spring Cloud Port Conflict 8888

java,spring,spring-boot,spring-cloud
I have a port conflict when starting a service and the configuration service is already running. I'm currently using Spring Boot 1.2.3.RELEASE and Spring Cloud version 1.0.0.RELEASE (tried with 1.0.1.RELEASE, same problem). If I start the config server in port 8888 and then try to start another service, it will...

How to access spring.application.instance_id programatically?

java,spring,spring-boot,spring-cloud,netflix-eureka
I have the following content in my "applicationname.yml" file of my Spring Boot/Cloud application. How can i get the value of spring.application.instance_id in my java code ? This "applicationname.yml" file is hosted in the 'Spring Cloud Config Server'. eureka: password: password client: registryFetchIntervalSeconds: 5 serviceUrl: defaultZone: ${vcap.services.${PREFIX:}eureka.credentials.uri:http://user:[email protected]:8761}/eureka/ instance: preferIpAddress: true...

Spring cloud: Ribbon and HTTPS

spring,spring-boot,spring-cloud
We want to use HTTPS for our microservices communication based on Feign and Ribbon. The services are based on spring boot and tomcat is correctly setup. The instances are registered with the HTTPS URL and securePort enabled on Eureka. However, when we call another microservice via Feign then the underlying...

Possible to use Spring Boot 1.3.0.M1 with Spring Cloud?

spring-boot,spring-cloud
I'd like to be able to start using Spring Boot 1.3.0.M1 (and by extension Spring 4.2.0.RC1) along with Spring Cloud (config server, eureka, ribbon, feign, and zuul). I'm using a gradle build, so initially I was using the dependencyManagement plugin like this: dependencyManagement { imports { mavenBom "org.springframework.cloud:spring-cloud-starter-parent:1.0.3.BUILD-SNAPSHOT" } }...

Can we use Spring-cloud-netflix and Hystrix to retry failed exectuion

java,spring,spring-boot,spring-cloud,hystrix
I am using Spring-Cloud-netflix library. I wonder if there is a way to take this code and add configure it instead of executing the fallback method right away to retry to execute it N times and in case of N times than execute the fallback method: @HystrixCommand(fallbackMethod = "defaultInvokcation") public...

How to read a file from URL using Spring Controller?

java,json,spring,spring-boot,spring-cloud
We have a JSON Schema definition file hosted in a server and accessible via an URL. My Spring Controller, needs to validate the incoming JSON data (from an Ajax Call) against this schema. Given the URL (like.. http://myservices.json.apiOneSchema.json) of the schema definition file, How can i read this schema definition...

Should it be possible to use @EnableFeignClients on a BootstrapConfiguration?

spring-cloud,netflix-feign
I'd like to use a feign client from a PropertySourceLocator which has to be registered during bootstrap. I have the following in my spring.factories: org.springframework.cloud.bootstrap.BootstrapConfiguration=\ test.PropertiesConfiguration with @Configuration @EnableFeignClients public class PropertiesConfiguration { @Bean public PropertySourceLocator propertySourceLocator() { return new MyPropertySourceLocator(); } } The feign client is autowired into MyPropertySourceLocator....

Integration Testing Spring Boot service using Eureka services

java,spring-boot,spring-cloud,service-discovery,netflix-eureka
I'm trying to figure out how to build integration tests on a Spring Boot application that uses Eureka. Say I have a test @WebAppConfiguration @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = {Application.class}) public class MyIntegrationTest { @Autowired protected WebApplicationContext webAppContext; protected MockMvc mockMvc; @Autowired RestTemplate restTemplate; @Before public void setup() { this.mockMvc = MockMvcBuilders.webAppContextSetup(this.webApplicationContext).build();...

Spring AWS SQS Reconnect After Losing Connection

spring,amazon-web-services,amazon-sqs,spring-cloud
I am using Spring Cloud AWS (1.0.1.RELEASE) with Spring Boot to run a SQS consumer. The application runs fine, but when it looses network connection (for instance if I switch my WIFI off on my laptop when it runs on it), I see errors on the console and the application...

Issue with hystrix fallback in spring cloud

spring-cloud,hystrix,netflix-feign
When I try to fallback using HystrixCommand in spring cloud, the method proxy is not working. The exception thrown in the in the method is not caught by the hystrix command aspect. I am facing this issue with Spring Cloud Hystrix integration. I'm using spring cloud 1.0.0.RC2 release. Here is...

Spring Cloud Samples Eureka - Docker - Use of underscore in link

docker,spring-boot,spring-cloud,netflix-eureka
I may have encountered an interesting anomaly with the use of Spring Cloud, Eureka and Docker. I am not sure if I have uncovered an issue or if the behavior is expected, but here is the gist. I start first with eureka running in a named docker container. Next, I...

Shared properties with Spring Cloud Config

spring,spring-cloud,spring-properties
We are thinking of migrating our Spring system to use Spring Cloud Config. The system is made up of multiple services and some share properties for common resources such as the DB datasource. For these we have a 'base' config file which contains the commonly used properties in one place....

Spring OAuth: Resource Server with Authorization Server backend

spring-security,oauth-2.0,spring-security-oauth2,spring-cloud
I want to develop two independent services, one for the business stuff and one for the user authentication using Spring OAuth 2 Let's call them Business-Service and OAuth-Service. Now I want the Business-Service delegate to the OAuth-Service if a request is not authenticated. The client application (an Android app) should...

From Spring data JPA Spring Cloud AWS

spring-data-jpa,porting,spring-cloud
I'm at design phase of my project and I have a doubt. I'm modelling my system and I will use Spring Data JPA for persistence layer. Although, there is high chances of cloud deploy. Is it traumatic the portability from Spring Data JPA to Spring Clous AWS (RDS)? I didn't...

How to use Spring Boot externalized configuration at Cloud Foundry

spring-boot,cloudfoundry,spring-cloud
For externalizing configuration in a spring Boot application, I follow the standard way of having an application.properties in the classpath. And then, in the production environment, I put another application.properties beside the JAR which overrides the earlier one. This way, I can have, say, a name property having different values...

Spring Boot with server.contextPath set vs. URL to hystrix.stream via Eureka Server

spring-cloud,turbine,hystrix,netflix-eureka
I have Eureka Server with Turbine instance running and a few discovery clients that are connected to it. Everything works fine, but if I register a discovery client that has server.contextPath set, it didn't get recognized by InstanceMonitor and Turbine stream is not able to combine its hystrix.stream. This is...

How to configure a custom RestTemplate when using spring-cloud-config-client?

java,spring,spring-cloud
I am trying to use spring-cloud-config-client to read my configuration properties from a spring-cloud-config-server application on startup. My application is a Spring-Boot application and what I need to do is adding a specific header to the request before it is sent to the config server. I have read the documentation...

Replacing RibbonRoutingFilter for my zuul application

ribbon,spring-cloud,netflix-zuul
I would like to replace the existing RibbonRoutingFilter that is embedded in the zuul package with a custom one that has additional characteristics/customizations. Is it just a case of creating my own and giving it is priority that triggers ahead of the builtin one? I don't want this to be...

Eureka peers not synchronized

spring-cloud,netflix,netflix-eureka
I'm prototyping a set of Spring Cloud + Netflix OSS applications and have run into trouble with Eureka. In our setup, we have a Spring Cloud Config Server + Eureka Server, and then 2 modules that utilize that server component for bootstrapping and service discovery. The problem I run into...

Zuul timing out in long-ish requests

spring-cloud,netflix-zuul
I am using a front end spring cloud application (micro service) acting as a zuul proxy (@EnableZuulProxy) to route requests from an external source to other internal micro services written using spring cloud (spring boot). The zuul server is straight out of the applications in the samples section @SpringBootApplication @Controller...

Disable Spring Cloud Server Config using profile?

spring-cloud
I want to achieve the following: when in 'dev' mode, embbed Spring Cloud Config in the current webapp when not in 'dev' mode, connect to the Spring Cloud Config server instance which is already running Thus my classpath for the current webapp contains dependencies to config server and client: <dependency>...

Spring cloud eureka client to multiple eureka servers

spring-cloud
I am able to get the eureka server to operate in a peer to peer mode. But one thing I am curious about is how do I get a service discovery client to register to multiple eureka servers. My use case is this: Say I have a service registering to...

Spring Cloud - Zuul Proxy is producing a No 'Access-Control-Allow-Origin' ajax response

java,spring,spring-boot,spring-cloud,netflix-zuul
Startup Appplication: @SpringBootApplication @EnableZuulProxy public class ZuulServer { public static void main(String[] args) { new SpringApplicationBuilder(ZuulServer.class).web(true).run(args); } } My YAML file is like this: server: port:8080 spring: application: name: zuul eureka: client: enabled: true serviceUrl: defaultZone: http://localhost:8761/eureka/ zuul: proxy: route: springapp: /springapp I have a microservice application (on port 8081)...

Error Injecting FeignClient from another Project

java,spring-cloud,component-scan,netflix-feign
I am having trouble auto wiring a feign client from another project. It appears that the implementation of the feign client is not being generated and injected. This is the error I am getting. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'passportRestController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException:...

AWS Instance Profile doesn't work with Spring Cloud AWS

java,amazon-web-services,spring-boot,spring-cloud
I have a small Spring Boot app, using Spring Cloud AWS (1.0.0.RELEASE) to access SQS queue. It is beeing deployed on an EC2 instance with Instance Profile set. It appears that AWS side of things is working, as I can access both relevant metadata links: iam/info and iam/security-credentials/role-name, and they...

Spring cloud consul class not found RestTemplateCustomizer

spring,spring-boot,spring-cloud,consul
I want to use spring cloud consul for Service discovery, but getting java.lang.ClassNotFoundException: org.springframework.cloud.client.loadbalancer.RestTemplateCustomizer , what am i missing here? my pom.xml <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-commons</artifactId>...

Can I force Eureka registrations to use an ip address instead of a hostname?

spring-cloud
I have a standalone, embedded Eureka server powered by Spring Boot 1.2.0.RELEASE and Spring Cloud 1.0.0.RC1. I see services properly registering themselves in the dashboard, which is great. The status links are using the host name of the box they are running on. Unfortunately, we are using virtual machines and...

Multiple Zuul routes to one service

spring-cloud,netflix-zuul
Most of the examples that I see are one route definition to one service. so this sort of thing: zuul: routes: myserver: path: /mypath/** Lets say that I want to route several routes to one service so in effect it would be like this: zuul: routes: myserver: path: /mypath/**, /anotherpath/**...

How to configure DS Replicas links in Spring Cloud Eureka Server Dashboard

spring,spring-cloud
I setup an Eureka cluster composed of 3 replicas. I got the nice dashboard which is automatically populated with the instances currently registered with Eureka and the DS Replicas. However the DS Replicas links seems to point to the value I set as eureka.client.serviceUrl.defaultZone. In my case this value is...

Setting datasources with Spring Cloud

spring,spring-cloud
I am looking for a SIMPLE example for setting a datasource (jdbc) from a configuration server running Spring Cloud. I've read through the Spring.io docs for Spring Cloud and find them VERY confusing. Does anyone know of a place to find a simple example? I've tried to run the stuff...

Spring Cloud - Config Client slows down metric /health

java,performance,spring-boot,spring-cloud
I am using the ConfigServer within my Spring Boot + Spring Cloud project. I used to monitor the endpoint /health, but since the ConfigClient asks the ConfigServer within every request, the invocation of the metric "/health" is quite slow. This is due to the fact, that for every request to...

using spring clound feign cause java.lang.NoClassDefFoundError: feign/Logger

spring-cloud,netflix-feign
I enabled my spring cloud for feignClients like this: @Configuration @EnableAutoConfiguration @RestController @EnableEurekaClient @EnableCircuitBreaker @EnableFeignClients public class SpringCloudConfigClientApplication { } But as oon as I add enableFeignClients, I got this error during compilation, java.lang.NoClassDefFoundError: feign/Logger at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2688) at java.lang.Class.getDeclaredMethods(Class.java:1962) My POM is <parent>...

Securing Eureka in Spring cloud

spring-cloud
I am curious about what options I have for securing a service connecting (registering and getting disco info) to eureka. Obviously I want to turn security on in Eureka and specify a username password for service. One question that I have is how do services trying to connect to eureka...

Hystrix Dashboard with Spring Boot Deployed On PCF not showing Metrics

spring,cloudfoundry,spring-cloud,hystrix
I created a simple app using Spring boot and the spring cloud starter hystrix library. In my build.gradle: dependencies { compile("org.springframework.boot:spring-boot-starter-web") compile("org.springframework.cloud:spring-cloud-starter-hystrix-dashboard:1.0.0.RC2") compile("org.springframework.cloud:spring-cloud-starter-hystrix:1.0.0.RC2") } I deployed one app as a hystrix dashboard using the above libraries and @EnableHystrixDashboard I then deployed another app which was annotated with @EnableHystrix I added...

spring cloud oauth sso without authorize step

spring,spring-security,spring-boot,spring-security-oauth2,spring-cloud
I have a spring cloud oauth @EnableAuthorizationServer that uses a jpa backend to store the accounts. I also have a couple of different clients, a website, an intranet and a ionic mobile app. all the clients have separate client credentials inline in the oauth config block. i have then tried...

Spring Cloud Netflix 1.0.0 RC2 breaks application

spring,spring-boot,spring-cloud
I have an application that is working fine with Spring Cloud Netflix 1.0.0.RC1. When I upgrade the same project to use RC2 artifacts, following exception comes during application startup. java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at...

How to Logout from Oauth2 SSO Server

java,single-sign-on,spring-security-oauth2,spring-cloud
I found tutorial about SSO https://github.com/dsyer/spring-security-angular/tree/master/oauth2 with configuration oauth2-authserver @Configuration @Order(-10) protected static class LoginConfig extends WebSecurityConfigurerAdapter { @Autowired private AuthenticationManager authenticationManager; @Override protected void configure(HttpSecurity http) throws Exception { // @formatter:off http .formLogin().loginPage("/login").permitAll() .and() .requestMatchers().antMatchers("/login", "/oauth/authorize", "/oauth/confirm_access") .and()...

How can I use Amazon Web Services policy statement in my Java application?

java,amazon-web-services,amazon-sqs,amazon-sns,spring-cloud
I want to send Amazon SNS Messages to Amazon SQS Queues from the backend Java application. According to SNS Developer Guide (http://docs.aws.amazon.com/sns/latest/dg/sns-dg.pdf), in the section "Sending Amazon SNS Messages to Amazon SQS Queues", under the topic - "Step 2. Give permission to the Amazon SNS topic to send messages to...

Microservices and cloud resource limitations

amazon-web-services,amazon-ec2,spring-cloud,microservices,amazon-elastic-beanstalk
I am at the beginning of a large migration from a single monolithic web service to a collection of microservices using Spring Cloud/Spring Cloud Netflix. Through my research of microservices I understand that the lines of demarcation between services should mirror the separations of concerns between them. An additional factor...

Hystrix getting access to the current execution state within fallback

spring-cloud,hystrix
I successfully configured spring-cloud (via spring-cloud-starter-hystrix) to wrap a call to a service. This all works fine and looks like the following: @Component public class MyService { @HystrixCommand(fallbackMethod = "fallback") public void longRunning() { // this could fail } public void fallback() { // fallback code } } My question...

How to config multiple Eureka Servers from client in Spring Cloud

spring-cloud,netflix-eureka
From the spring doc, I see we can have peer eureka server together, so for Eureka1, in application.yml, I can have: spring: profiles: peer1 eureka: instance: hostname: peer1 client: serviceUrl: defaultZone: http://peer2/eureka/ And in Eureka Server 2, I can have: spring: profiles: peer2 eureka: instance: hostname: peer2 client: serviceUrl: defaultZone:...