Skip to content

Error creating bean halJacksonHttpMessageConverter when bump spring-hateoas from 1.2.5 to 1.3.0 #1528

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Emma0s opened this issue May 7, 2021 · 2 comments

Comments

@Emma0s
Copy link

Emma0s commented May 7, 2021

when i bump spring-hateoas from 1.2.5 to 1.3.0. I get the stacktrace below.

Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'halJacksonHttpMessageConverter' defined in class path resource [org/springframework/cloud/openfeign/hateoas/FeignHalAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.hateoas.server.mvc.TypeConstrainedMappingJackson2HttpMessageConverter]: Factory method 'halJacksonHttpMessageConverter' threw exception; nested exception is java.lang.NoSuchMethodError: 'void org.springframework.hateoas.mediatype.hal.Jackson2HalModule$HalHandlerInstantiator.<init>(org.springframework.hateoas.server.LinkRelationProvider, org.springframework.hateoas.mediatype.hal.CurieProvider, org.springframework.hateoas.mediatype.MessageResolver, org.springframework.hateoas.mediatype.hal.HalConfiguration)'
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1334)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:564)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1605)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1562)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveMultipleBeans(DefaultListableBeanFactory.java:1406)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1338)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory$DependencyObjectProvider.resolveStream(DefaultListableBeanFactory.java:2108)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory$DependencyObjectProvider.orderedStream(DefaultListableBeanFactory.java:2102)
	at org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration.messageConverters(HttpMessageConvertersAutoConfiguration.java:70)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
	... 135 more
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.hateoas.server.mvc.TypeConstrainedMappingJackson2HttpMessageConverter]: Factory method 'halJacksonHttpMessageConverter' threw exception; nested exception is java.lang.NoSuchMethodError: 'void org.springframework.hateoas.mediatype.hal.Jackson2HalModule$HalHandlerInstantiator.<init>(org.springframework.hateoas.server.LinkRelationProvider, org.springframework.hateoas.mediatype.hal.CurieProvider, org.springframework.hateoas.mediatype.MessageResolver, org.springframework.hateoas.mediatype.hal.HalConfiguration)'
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
	... 157 more
Caused by: java.lang.NoSuchMethodError: 'void org.springframework.hateoas.mediatype.hal.Jackson2HalModule$HalHandlerInstantiator.<init>(org.springframework.hateoas.server.LinkRelationProvider, org.springframework.hateoas.mediatype.hal.CurieProvider, org.springframework.hateoas.mediatype.MessageResolver, org.springframework.hateoas.mediatype.hal.HalConfiguration)'
	at org.springframework.cloud.openfeign.hateoas.FeignHalAutoConfiguration.halJacksonHttpMessageConverter(FeignHalAutoConfiguration.java:75)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
	... 158 more

looks like it cannot find constructor when HalHandlerInstantiator, cause there‘s no 4-argument construction method here

Jackson2HalModule.HalHandlerInstantiator halHandlerInstantiator = new Jackson2HalModule.HalHandlerInstantiator(
				linkRelationProvider.getIfAvailable(), curieProviderInstance, messageResolver.getIfAvailable(),
				configuration);

Do you have any suggestion about this issue?

@odrotbohm
Copy link
Member

In its currently release version, Spring Cloud doesn't seem to prepared to accommodate the changes made in the minor release of Spring HATEOAS. Can you leave a few words on what kind of upgrade you're trying to achieve in the first place? Is it a Boot upgrade? Is it as HATEOAS upgrade only? If so, what's the reason behind those upgrades?

While it's generally only recommended to use Spring Cloud versions with the dependencies declared compatible more information on your upgrade scenario would help us to find out, what we could do to mitigate the pain.

@Emma0s
Copy link
Author

Emma0s commented May 8, 2021

Thanks for your reply. I decide to use org.springframework.boot:spring-boot-starter-hateoas instead of org.springframework.hateoas:spring-hateoas to make hateoas accommodate with spring cloud version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants