开发者社区> 问答> 正文

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

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

展开
收起
不喝酒的李白 2019-03-01 10:12:08 6086 0
2 条回答
写回答
取消 提交回答
  • 遇到相同异常。以下是排查过程,希望对搜到这个问题的人有帮助

    看最后一个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的方式

    2020-03-23 13:46:01
    赞同 展开评论 打赏
  • 1.阿里云大学讲师,主讲《微服务Spring Cloud设计与开发实战》《MongoDB高级实战》等课程 2.MongoDB中文社区专家 3.《MongoDB实战》第2版译者 5.吉林大学计算机科学学士、上海交通大学硕士

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

    2019-07-17 23:29:54
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
如何运维千台以上游戏云服务器 立即下载
网站/服务器取证 实践与挑战 立即下载
蚂蚁金服高级开发工程师萧恺:IDEA 插件开发入门教程 立即下载

相关镜像