These are chat archives for spring-cloud/spring-cloud

8th
Jan 2018
Joe
@JoeKerouac
Jan 08 2018 10:11
org.xml.sax.SAXException: Invalid system identifier: http://mybatis.org/dtd/mybatis-3-config.dtd
why
help
Mark Paluch
@mp911de
Jan 08 2018 11:44
@935237604 this is not a chat room for generic programming issues
maskleo
@maskleo
Jan 08 2018 12:02
check your mybatis xml @935237604
Denis Stepanov
@dstepanov
Jan 08 2018 15:43

Hi, I have asked a few posts above. Does anybody know why I'm getting timeout exceptions with service alias instead of real ip:

feign.RetryableException: Read timed out executing POST http://alias-of-service/endpoint
        at feign.FeignException.errorExecuting(FeignException.java:67)
        at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:102)
        at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:76)
        at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:103)
        at com.sun.proxy.$Proxy178.pay(Unknown Source)

?
Can there be a problem inside Spring and at some point alias is accessed instead if the service's address?

Dave Syer
@dsyer
Jan 08 2018 15:44
It's either one thing or the other. It's not going to start being a physical address if it was a virtual one.
It's not clear from your question. Sounds like it sometimes works for this client?
Denis Stepanov
@dstepanov
Jan 08 2018 15:45
Yes, it's random
Dave Syer
@dsyer
Jan 08 2018 15:45
My guess is it really timed out then
Hard to say for sure
Denis Stepanov
@dstepanov
Jan 08 2018 15:47
Is there a way not to use LoadBalancerFeignClient?
Dave Syer
@dsyer
Jan 08 2018 15:48
Give it a physical address?
Denis Stepanov
@dstepanov
Jan 08 2018 15:49
I have load balancing disabled and I want to bypass all that calls to AbstractLoadBalancerAwareClient
Dave Syer
@dsyer
Jan 08 2018 15:50
Don't know really. Can't you just give it a physical address in @FeignClient(url=...)?
Denis Stepanov
@dstepanov
Jan 08 2018 16:01
I would like just to change properties to see if exceptions are going to disappear
Tyler Thrailkill
@snowe2010
Jan 08 2018 16:44
Does anyone know why spring.factories are not able to access configuration properties when initializing?
I'm trying to create a pr for spring-cloud-kubernetes for this bug spring-cloud-incubator/spring-cloud-kubernetes#131
Dave Syer
@dsyer
Jan 08 2018 16:45
What do you mean by "initializing"?
They are instantiated using their default constructor. There is no context.
Tyler Thrailkill
@snowe2010
Jan 08 2018 16:46
when the constructor is called.
Dave Syer
@dsyer
Jan 08 2018 16:46
It's the default constructor. You don't get any "configuration properties"
Tyler Thrailkill
@snowe2010
Jan 08 2018 16:47
? even using @ConfigurationProperties or @Value?
Dave Syer
@dsyer
Jan 08 2018 16:47
I don't follow what you mean
The default constructor has no arguments
There is no context
It depends what kind of factory you mean though
Tyler Thrailkill
@snowe2010
Jan 08 2018 16:48

@ConditionalOnProperty(value = "spring.cloud.kubernetes.enabled", matchIfMissing = true)
public class KubernetesApplicationContextInitializer implements
    ApplicationContextInitializer<ConfigurableApplicationContext>, Ordered {

    private final KubernetesProfileApplicationListener listener;
    private static final int ORDER = 100;

    @Value("${spring.cloud.kubernetes.enabled}")
    String springcloudkubernetesenabled;


    public KubernetesApplicationContextInitializer() {
        //If we are inside Kubernetes this should be perfectly valid.
        //If not then we won't add the Kubernetes profile anyway.
        this(new StandardPodUtils(new DefaultKubernetesClient()));
    }

    public KubernetesApplicationContextInitializer(PodUtils utils) {
        this(new KubernetesProfileApplicationListener(utils));
    }

    public KubernetesApplicationContextInitializer(KubernetesProfileApplicationListener listener) {
        this.listener = listener;
    }

    @Override
    public int getOrder() {
        return ORDER;
    }

    @Override
    public void initialize(ConfigurableApplicationContext applicationContext) {
        listener.addKubernetesProfile(applicationContext.getEnvironment());
    }
}
should that be possible? I've modified an existing class and just added 3 lines.
should springcloudkubernetesenabled be populated there?
Dave Syer
@dsyer
Jan 08 2018 16:49
And this class is listed in spring.factories as an ApplicationContextInitializer?
Tyler Thrailkill
@snowe2010
Jan 08 2018 16:49
yes
Dave Syer
@dsyer
Jan 08 2018 16:50
It is created from the default constructor
There is no context
Anything that is conditional about its behaviour would have to go in the initialize() method.
Tyler Thrailkill
@snowe2010
Jan 08 2018 16:52
I don't see what creating from the default constructor has to do with populating the value, as I don't understand the internals of spring (I'm able to populate @Values in plenty of classes that are just instantiated from their default constructors), but I guess you mean that the properties are loaded but not ever passed to the class.
the initialize method isn't hit before the constructor completes.
Dave Syer
@dsyer
Jan 08 2018 16:52
Of course
You can't call a method on an instance until it exists
Tyler Thrailkill
@snowe2010
Jan 08 2018 16:52
to fix that bug I would need to move the construction of the defaultkubernetesclient into the initialize method
yea I understand that, just speaking my thoughts out loud here
i don't see how I can move the constructor logic into the initialize method.
I won't be able to call this from initialize.
what is the pattern the spring team uses for conditional behavior from properties in this situation?
Tyler Thrailkill
@snowe2010
Jan 08 2018 16:59
I think I didn't explain the problem well enough. The constructor calls new DefaultKubernetesClient() which does a ton of stuff that causes immediate failure (due to running on a system without kubernetes), so the initialize() method is never hit.
So I need to move instantiation of the client to the initialize method somehow, but I do not see how to accomplish that.
Denis Stepanov
@dstepanov
Jan 08 2018 17:33
@dsyer Looks like FeignLoadBalancer is setting clientConfig.get(CommonClientConfigKey.ReadTimeout) which is 1second in my configuration. What is the correct way to override that property?
Spencer Gibb
@spencergibb
Jan 08 2018 17:42
@dstepanov ribbon.<clientid>.ReadTimeout=value