hapi-fhir icon indicating copy to clipboard operation
hapi-fhir copied to clipboard

Annotation client conflicts with spring-data-jpa

Open krumboeck opened this issue 3 years ago • 0 comments

Describe the bug Application throws exception:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fhirRepository' defined in class path resource [at/noevh/fhir/transfer/config/FhirConfig.class]: Unexpected exception during bean creation; nested exception is java.lang.UnsupportedOperationException: HAPI-1403: The method 'hashCode' in type Object has no handler. Did you forget to annotate it with a RESTful method annotation?
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.20.jar:5.3.20]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.20.jar:5.3.20]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[spring-boot-2.7.0.jar:2.7.0]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) ~[spring-boot-2.7.0.jar:2.7.0]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-2.7.0.jar:2.7.0]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-2.7.0.jar:2.7.0]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[spring-boot-2.7.0.jar:2.7.0]
	at at.noevh.fhir.transfer.Application.main(Application.java:35) ~[classes/:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
	at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.7.0.jar:2.7.0]
Caused by: java.lang.UnsupportedOperationException: HAPI-1403: The method 'hashCode' in type Object has no handler. Did you forget to annotate it with a RESTful method annotation?
	at ca.uhn.fhir.rest.client.impl.ClientInvocationHandler.invoke(ClientInvocationHandler.java:71) ~[hapi-fhir-client-6.0.2.jar:na]
	at com.sun.proxy.$Proxy71.hashCode(Unknown Source) ~[na:na]
	at java.base/java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:936) ~[na:na]
	at java.base/java.util.concurrent.ConcurrentHashMap.containsKey(ConcurrentHashMap.java:964) ~[na:na]
	at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.requiresDestruction(PersistenceAnnotationBeanPostProcessor.java:372) ~[spring-orm-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.DisposableBeanAdapter.hasApplicableProcessors(DisposableBeanAdapter.java:425) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractBeanFactory.requiresDestruction(AbstractBeanFactory.java:1911) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractBeanFactory.registerDisposableBeanIfNecessary(AbstractBeanFactory.java:1929) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:661) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.20.jar:5.3.20]
	... 18 common frames omitted

To Reproduce Steps to reproduce the behavior:

  1. Create a simple spring boot application
  2. Instantiate a simple annotation based client
  3. Add spring-boot-starter-data-jpa

Environment (please complete the following information):

  • HAPI FHIR 6.0.2 (and at least also 5.7.0)
  • Spring Boot 2.7.0
  • Spring Data JPA 2.7.0

Spring boot config

	@Bean
	public BasicAuthInterceptor basicAuthInterceptor() {
		return new BasicAuthInterceptor(username, password);
	}

	@Bean
	public FhirContext fhirContextDSTU3() {
		FhirContext context = FhirContext.forDstu3();
		context.getRestfulClientFactory().setConnectTimeout(20 * 1000);
		context.getRestfulClientFactory().setSocketTimeout(20 * 1000);
		return context;
	}

	@Bean
	public FhirRepository fhirRepository() {
		FhirRepository repo = fhirContextDSTU3().newRestfulClient(FhirRepository.class, serverBase);
		repo.registerInterceptor(basicAuthInterceptor());
		repo.setEncoding(EncodingEnum.JSON);
		repo.setPrettyPrint(true);
		return repo;
	}

krumboeck avatar Jun 22 '22 09:06 krumboeck