springcloud maven项目 在本地用idea运行可以,放阿里云服务器报错-问答-阿里云开发者社区-阿里云

开发者社区> 问答> 正文

springcloud maven项目 在本地用idea运行可以,放阿里云服务器报错

不喝酒的李白 2019-03-01 10:12:08 2956

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.eurekaApplicationInfoManager' defined in class path resource [org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.netflix.appinfo.ApplicationInfoManager]: Factory method 'eurekaApplicationInfoManager' threw exception; nested exception is java.lang.NullPointerException
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:590) ~[spring-beans-5.0.7.RELEASE.jar!/:5.0.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1256) ~[spring-beans-5.0.7.RELEASE.jar!/:5.0.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1105) ~[spring-beans-5.0.7.RELEASE.jar!/:5.0.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) ~[spring-beans-5.0.7.RELEASE.jar!/:5.0.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:503) ~[spring-beans-5.0.7.RELEASE.jar!/:5.0.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$1(AbstractBeanFactory.java:353) ~[spring-beans-5.0.7.RELEASE.jar!/:5.0.7.RELEASE]
    at org.springframework.cloud.context.scope.GenericScope$BeanLifecycleWrapper.getBean(GenericScope.java:390) ~[spring-cloud-context-2.0.0.RELEASE.jar!/:2.0.0.RELEASE]
    at org.springframework.cloud.context.scope.GenericScope.get(GenericScope.java:184) ~[spring-cloud-context-2.0.0.RELEASE.jar!/:2.0.0.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:350) ~[spring-beans-5.0.7.RELEASE.jar!/:5.0.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.7.RELEASE.jar!/:5.0.7.RELEASE]
    at org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:35) ~[spring-aop-5.0.7.RELEASE.jar!/:5.0.7.RELEASE]
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:672) ~[spring-aop-5.0.7.RELEASE.jar!/:5.0.7.RELEASE]
    at com.netflix.appinfo.ApplicationInfoManager

$$ EnhancerBySpringCGLIB $$

59479076.getInfo() ~[eureka-client-1.9.2.jar!/:1.9.2]
    at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaServiceRegistry.maybeInitializeClient(EurekaServiceRegistry.java:56) ~[spring-cloud-netflix-eureka-client-2.0.0.RELEASE.jar!/:2.0.0.RELEASE]
    at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaServiceRegistry.register(EurekaServiceRegistry.java:39) ~[spring-cloud-netflix-eureka-client-2.0.0.RELEASE.jar!/:2.0.0.RELEASE]
    at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaAutoServiceRegistration.start(EurekaAutoServiceRegistration.java:80) ~[spring-cloud-netflix-eureka-client-2.0.0.RELEASE.jar!/:2.0.0.RELEASE]
    at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:181) ~[spring-context-5.0.7.RELEASE.jar!/:5.0.7.RELEASE]
    ... 22 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.netflix.appinfo.ApplicationInfoManager]: Factory method 'eurekaApplicationInfoManager' threw exception; nested exception is java.lang.NullPointerException
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.0.7.RELEASE.jar!/:5.0.7.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:582) ~[spring-beans-5.0.7.RELEASE.jar!/:5.0.7.RELEASE]
    ... 38 common frames omitted
Caused by: java.lang.NullPointerException: null
    at java.lang.String.replace(String.java:2240) ~[na:1.8.0_201]
    at com.netflix.appinfo.InstanceInfo$Builder.setStatusPageUrl(InstanceInfo.java:617) ~[eureka-client-1.9.2.jar!/:1.9.2]
    at org.springframework.cloud.netflix.eureka.InstanceInfoFactory.create(InstanceInfoFactory.java:61) ~[spring-cloud-netflix-eureka-client-2.0.0.RELEASE.jar!/:2.0.0.RELEASE]
    at org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration.eurekaApplicationInfoManager(EurekaClientAutoConfiguration.java:278) ~[spring-cloud-netflix-eureka-client-2.0.0.RELEASE.jar!/:2.0.0.RELEASE]
    at org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration

$$ EnhancerBySpringCGLIB $$

efe7787f.CGLIB$eurekaApplicationInfoManager$0() ~[spring-cloud-netflix-eureka-client-2.0.0.RELEASE.jar!/:2.0.0.RELEASE]
    at org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration

$$ EnhancerBySpringCGLIB $$

efe7787f

$$ FastClassBySpringCGLIB $$

49aa0745.invoke() ~[spring-cloud-netflix-eureka-client-2.0.0.RELEASE.jar!/:2.0.0.RELEASE]
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-5.0.7.RELEASE.jar!/:5.0.7.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361) ~[spring-context-5.0.7.RELEASE.jar!/:5.0.7.RELEASE]
    at org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration

$$ EnhancerBySpringCGLIB $$

efe7787f.eurekaApplicationInfoManager() ~[spring-cloud-netflix-eureka-client-2.0.0.RELEASE.jar!/:2.0.0.RELEASE]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_201]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_201]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_201]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_201]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.0.7.RELEASE.jar!/:5.0.7.RELEASE]
    ... 39 common frames omitted

Java Maven
分享到
取消 提交回答
全部回答(2)
  • sslin
    2020-03-23 13:46:01

    遇到相同异常。以下是排查过程,希望对搜到这个问题的人有帮助

    看最后一个cause by:

    Caused by: java.lang.NullPointerException: null
        at java.lang.String.replace(String.java:2240) ~[na:1.8.0_201]
        at com.netflix.appinfo.InstanceInfo$Builder.setStatusPageUrl(InstanceInfo.java:617) ~[eureka-client-1.9.2.jar!/:1.9.2]
        at org.springframework.cloud.netflix.eureka.InstanceInfoFactory.create(InstanceInfoFactory.java:61) ~[spring-cloud-netflix-eureka-client-2.0.0.RELEASE.jar!/:2.0.0.RELEASE]
    

    查看响应源码的位置,发现是hostName为空。

    继续查看hostName的获取方式,因为我们项目设置了 eureka的prefer-ip-address: true 和ip-address,所以hostName取的是ip-address的值,推断ip-address设置的值是空的。

    我们项目中的ip-address是通过HOST环境变量设置的,检查发现HOST环境变量为空,设置环境变量后问题解决。

    所以,检查一下设置eureka hostName的方式

    0 0
  • 徐雷frank
    2019-07-17 23:29:54

    检查一下看看 自己定义的包 scopedTarget.eurekaApplicationInfoManager,这个类型在的包jar文件 是不是没有部署上去?

    0 0
添加回答
开发与运维
使用钉钉扫一扫加入圈子
+ 订阅

集结各类场景实战经验,助你开发运维畅行无忧

推荐文章
相似问题
推荐课程