From 67e67bbf44a76e4c16ebbed307e8313b9c3b2320 Mon Sep 17 00:00:00 2001 From: jmarchionatto <60409882+jmarchionatto@users.noreply.github.com> Date: Tue, 19 Jul 2022 10:00:28 -0400 Subject: [PATCH] Issue 3804 application fails to start 610 pre14 snapshot with beandefinitionoverrideexception invalid bean definition with name loadidsstep (#3805) * shared steps * Add changelog Co-authored-by: leif stawnyczy Co-authored-by: juan.marchionatto --- ...s-because-of-duplicated-bean-definition.yaml | 5 +++++ .../uhn/fhir/batch2/jobs/config/SharedCtx.java | 15 +++++++++++++++ .../jobs/expunge/DeleteExpungeAppCtx.java | 9 ++------- .../fhir/batch2/jobs/reindex/ReindexAppCtx.java | 17 +++++++---------- 4 files changed, 29 insertions(+), 17 deletions(-) create mode 100644 hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_1_0/3804-app-start-fails-because-of-duplicated-bean-definition.yaml create mode 100644 hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/config/SharedCtx.java diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_1_0/3804-app-start-fails-because-of-duplicated-bean-definition.yaml b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_1_0/3804-app-start-fails-because-of-duplicated-bean-definition.yaml new file mode 100644 index 00000000000..da2e4946318 --- /dev/null +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_1_0/3804-app-start-fails-because-of-duplicated-bean-definition.yaml @@ -0,0 +1,5 @@ +--- +type: fix +issue: 3804 +title: "When starting hapi-fhir from starter application, BeanDefinitionOverrideException was thrown with message: Invalid bean + definition with name loadIdsStep. This issue is now fixed." diff --git a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/config/SharedCtx.java b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/config/SharedCtx.java new file mode 100644 index 00000000000..48f01e823a7 --- /dev/null +++ b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/config/SharedCtx.java @@ -0,0 +1,15 @@ +package ca.uhn.fhir.batch2.jobs.config; + +import ca.uhn.fhir.batch2.jobs.step.LoadIdsStep; +import ca.uhn.fhir.jpa.api.svc.IBatch2DaoSvc; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class SharedCtx { + + @Bean + public LoadIdsStep loadIdsStep(IBatch2DaoSvc theBatch2DaoSvc) { + return new LoadIdsStep(theBatch2DaoSvc); + } +} diff --git a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/expunge/DeleteExpungeAppCtx.java b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/expunge/DeleteExpungeAppCtx.java index cf7377e7aa3..7158147674c 100644 --- a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/expunge/DeleteExpungeAppCtx.java +++ b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/expunge/DeleteExpungeAppCtx.java @@ -22,9 +22,9 @@ package ca.uhn.fhir.batch2.jobs.expunge; import ca.uhn.fhir.batch2.jobs.chunk.PartitionedUrlChunkRangeJson; import ca.uhn.fhir.batch2.jobs.chunk.ResourceIdListWorkChunkJson; +import ca.uhn.fhir.batch2.jobs.config.SharedCtx; import ca.uhn.fhir.batch2.jobs.parameters.UrlListValidator; import ca.uhn.fhir.batch2.jobs.step.GenerateRangeChunksStep; -import ca.uhn.fhir.batch2.jobs.step.LoadIdsStep; import ca.uhn.fhir.batch2.model.JobDefinition; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.jpa.api.svc.IBatch2DaoSvc; @@ -36,7 +36,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration -public class DeleteExpungeAppCtx { +public class DeleteExpungeAppCtx extends SharedCtx { public static final String JOB_DELETE_EXPUNGE = "DELETE_EXPUNGE"; @@ -87,11 +87,6 @@ public class DeleteExpungeAppCtx { return new GenerateRangeChunksStep(); } - @Bean - public LoadIdsStep loadIdsStep(IBatch2DaoSvc theBatch2DaoSvc) { - return new LoadIdsStep(theBatch2DaoSvc); - } - @Bean public DeleteExpungeProvider deleteExpungeProvider(FhirContext theFhirContext, IDeleteExpungeJobSubmitter theDeleteExpungeJobSubmitter) { return new DeleteExpungeProvider(theFhirContext, theDeleteExpungeJobSubmitter); diff --git a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/ReindexAppCtx.java b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/ReindexAppCtx.java index 715902e9002..ce5da7e2b8b 100644 --- a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/ReindexAppCtx.java +++ b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/ReindexAppCtx.java @@ -23,10 +23,10 @@ package ca.uhn.fhir.batch2.jobs.reindex; import ca.uhn.fhir.batch2.api.IJobCoordinator; import ca.uhn.fhir.batch2.jobs.chunk.PartitionedUrlChunkRangeJson; import ca.uhn.fhir.batch2.jobs.chunk.ResourceIdListWorkChunkJson; +import ca.uhn.fhir.batch2.jobs.config.SharedCtx; import ca.uhn.fhir.batch2.jobs.parameters.UrlListValidator; import ca.uhn.fhir.batch2.jobs.parameters.UrlPartitioner; import ca.uhn.fhir.batch2.jobs.step.GenerateRangeChunksStep; -import ca.uhn.fhir.batch2.jobs.step.LoadIdsStep; import ca.uhn.fhir.batch2.model.JobDefinition; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.jpa.api.svc.IBatch2DaoSvc; @@ -36,7 +36,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration -public class ReindexAppCtx { +public class ReindexAppCtx extends SharedCtx { public static final String JOB_REINDEX = "REINDEX"; @@ -67,6 +67,11 @@ public class ReindexAppCtx { .build(); } + @Bean + public GenerateRangeChunksStep reindexGenerateRangeChunksStep() { + return new GenerateRangeChunksStep(); + } + @Bean public ReindexJobParametersValidator reindexJobParametersValidator(IBatch2DaoSvc theBatch2DaoSvc) { return new ReindexJobParametersValidator(new UrlListValidator(ProviderConstants.OPERATION_REINDEX, theBatch2DaoSvc)); @@ -77,15 +82,7 @@ public class ReindexAppCtx { return new ReindexStep(); } - @Bean - public GenerateRangeChunksStep reindexGenerateRangeChunksStep() { - return new GenerateRangeChunksStep(); - } - @Bean - public LoadIdsStep loadIdsStep(IBatch2DaoSvc theBatch2DaoSvc) { - return new LoadIdsStep(theBatch2DaoSvc); - } @Bean public ReindexProvider reindexProvider(FhirContext theFhirContext, IJobCoordinator theJobCoordinator, IRequestPartitionHelperSvc theRequestPartitionHelperSvc, UrlPartitioner theUrlPartitioner) {