Index: oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/osgi/RepositoryManager.java =================================================================== --- oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/osgi/RepositoryManager.java (revision 1701798) +++ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/osgi/RepositoryManager.java (working copy) @@ -107,6 +107,8 @@ description = "Whether the query result size should return an estimation (or -1 if disabled) for large queries") private static final String FAST_QUERY_RESULT_SIZE = "oak.query.fastResultSize"; + private OsgiRepository repository; + @Activate public void activate(BundleContext bundleContext, Map config) throws Exception { observationQueueLength = PropertiesUtil.toInteger(prop( @@ -148,8 +150,14 @@ public void deactivate() { if (registration != null) { registration.unregister(); + registration = null; } + if (repository != null) { + repository.shutdown(); + repository = null; + } + initializers.stop(); indexProvider.stop(); indexEditorProvider.stop(); @@ -175,10 +183,15 @@ oak.with(commitRateLimiter); } - return bundleContext.registerService( - Repository.class.getName(), - new OsgiRepository(oak.createContentRepository(), whiteboard, securityProvider, - observationQueueLength, commitRateLimiter, fastQueryResultSize), - new Properties()); + repository = new OsgiRepository( + oak.createContentRepository(), + whiteboard, + securityProvider, + observationQueueLength, + commitRateLimiter, + fastQueryResultSize + ); + + return bundleContext.registerService(Repository.class.getName(), repository, new Properties()); } }