diff --git a/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrRepositorySessionFactory.java b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrRepositorySessionFactory.java index 8589ecbdd..1c51dfc73 100644 --- a/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrRepositorySessionFactory.java +++ b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrRepositorySessionFactory.java @@ -57,7 +57,7 @@ public class JcrRepositorySessionFactory @Inject private Repository repository; - @Inject + // Lazy evaluation to avoid problems with circular dependencies during initialization private MetadataResolver metadataResolver; @Inject @@ -75,7 +75,7 @@ public class JcrRepositorySessionFactory // API. MetadataRepository metadataRepository = new JcrMetadataRepository( metadataFacetFactories, repository ); - return new RepositorySession( metadataRepository, metadataResolver ); + return new RepositorySession( metadataRepository, getMetadataResolver() ); } catch ( RepositoryException e ) { @@ -84,6 +84,14 @@ public class JcrRepositorySessionFactory } } + // Lazy evaluation to avoid problems with circular dependencies during initialization + private MetadataResolver getMetadataResolver() { + if (this.metadataResolver==null) { + this.metadataResolver = applicationContext.getBean( MetadataResolver.class ); + } + return this.metadataResolver; + } + @PostConstruct public void initialize() throws Exception