DiscoveryClient @FineGrainedLazySingleton cglib NullPointer issue

116 views
Skip to first unread message

stephen dillon

unread,
Oct 27, 2015, 4:53:18 PM10/27/15
to eureka_netflix
Doing some investigation into eureka and encountering a issue working with the discovery client.
The service starts and registers with my eureka server (Using Spring Boot eureka server and separate app using the client) but when i auto-wire, the first calls triggers the lazy singleton and the cglib proxy hides what causes the NullPointerException.
Using the latest Spring boot release.
The project is public and only requires gradle to build (Run wod-lake-eureka for server and wod-lake-user-data for client)


Stack trace is below, cglib seems to hide any details that would help debugging.
Its probably something missing in my project configuration, but the cglib proxying / lazy initialization makes it quite impossible to detect the issue.
Any suggestions debugging this would be greatly appreciated!

2015-10-27 16:33:21.205  INFO 9468 --- [           main] c.netflix.config.DynamicPropertyFactory  : DynamicPropertyFactory is initialized with configuration sources: com.netflix.config.ConcurrentCompositeConfiguration@2dd8239
Printing services
org.springframework.cloud.netflix.eureka.EurekaDiscoveryClient@2bebb74f
2015-10-27 16:33:21.227  WARN 9468 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sampleService' defined in file [C:\code\wod-lake\wod-lake-user-data\bin\org\yodes\wod\lake\eureka\services\SampleService.class]: Invocation of init method failed; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:957)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:946)
at org.yodes.wod.lake.eureka.Application.main(Application.java:12)
Caused by: java.lang.NullPointerException: null
at com.netflix.discovery.DiscoveryClient$$FastClassBySpringCGLIB$$a84c8cb4.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:717)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133)
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653)
at com.netflix.discovery.DiscoveryClient$$EnhancerBySpringCGLIB$$ff3181d5.getApplications(<generated>)
at org.springframework.cloud.netflix.eureka.EurekaDiscoveryClient.getServices(EurekaDiscoveryClient.java:133)
at org.yodes.wod.lake.eureka.services.SampleService.afterPropertiesSet(SampleService.java:18)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1633)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)
... 15 common frames omitted

Stephen Dillon

unread,
Oct 29, 2015, 4:08:32 PM10/29/15
to eureka_netflix
Found a fix if not the issue.
This was thrown when running a test under @WebAppConfiguration instead of using the @WebIntegrationTest
Also need to set the property to pull the registry, which will return nothing if not set (A error would probably be more appropriate)
eureka.client.fetchRegistry=true
Reply all
Reply to author
Forward
0 new messages