0
votes

I am having spring Mongodb app, I wanted to take it to Azure. So, I decided to use Cosmos db. I made following changes to my application.properties file spring.data.mongodb.uri = mongodb://[username]:[password]@[dbname].documents.azure.com:10255/?ssl=true spring.data.mongodb.database=dbname

I am getting following exception: ActivityId: 25611363-0000-0000-0000-000000000000, Request URI: /apps/bbbd93b0-83ee-44a2-9015-ca7226457764/services/63c75889-e342-42b3-81b0-4851cae426d7/partitions/89ba02e8-b034-4b75-b8a0-57194d79f785/replicas/131587440168033880p, RequestStats: , SDK: Microsoft.Azure.Documents.Common/1.19.121.4' on server dz5prdddc02-docdb-1.documents.azure.com:10255. The full response is { "_t" : "OKMongoResponse", "ok" : 0, "code" : 2, "errmsg" : "Message: {\"Errors\":[\"Too many 'included' paths (106) specified in policy. A maximum of 100 is allowed.\"]}\r\nActivityId: 25611363-0000-0000-0000-000000000000, Request URI: /apps/bbbd93b0-83ee-44a2-9015-ca7226457764/services/63c75889-e342-42b3-81b0-4851cae426d7/partitions/89ba02e8-b034-4b75-b8a0-57194d79f785/replicas/131587440168033880p, RequestStats: , SDK: Microsoft.Azure.Documents.Common/1.19.121.4", "$err" : "Message: {\"Errors\":[\"Too many 'included' paths (106) specified in policy. A maximum of 100 is allowed.\"]}\r\nActivityId: 25611363-0000-0000-0000-000000000000, Request URI: /apps/bbbd93b0-83ee-44a2-9015-ca7226457764/services/63c75889-e342-42b3-81b0-4851cae426d7/partitions/89ba02e8-b034-4b75-b8a0-57194d79f785/replicas/131587440168033880p, RequestStats: , SDK: Microsoft.Azure.Documents.Common/1.19.121.4" } at org.springframework.data.mongodb.core.MongoExceptionTranslator.translateExceptionIfPossible(MongoExceptionTranslator.java:107) ~[spring-data-mongodb-1.10.9.RELEASE.jar:na] at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexCreator.createIndex(MongoPersistentEntityIndexCreator.java:162) ~[spring-data-mongodb-1.10.9.RELEASE.jar:na] at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexCreator.checkForAndCreateIndexes(MongoPersistentEntityIndexCreator.java:133) ~[spring-data-mongodb-1.10.9.RELEASE.jar:na] at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexCreator.checkForIndexes(MongoPersistentEntityIndexCreator.java:125) ~[spring-data-mongodb-1.10.9.RELEASE.jar:na] at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexCreator.(MongoPersistentEntityIndexCreator.java:91) ~[spring-data-mongodb-1.10.9.RELEASE.jar:na] at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexCreator.(MongoPersistentEntityIndexCreator.java:68) ~[spring-data-mongodb-1.10.9.RELEASE.jar:na] at org.springframework.data.mongodb.core.MongoTemplate.(MongoTemplate.java:233) ~[spring-data-mongodb-1.10.9.RELEASE.jar:na] at org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration.mongoTemplate(MongoDataAutoConfiguration.java:101) ~[spring-boot-autoconfigure-1.5.9.RELEASE.jar:1.5.9.RELEASE] at org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration$$EnhancerBySpringCGLIB$$7c4704f8.CGLIB$mongoTemplate$1() ~[spring-boot-autoconfigure-1.5.9.RELEASE.jar:1.5.9.RELEASE] at org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration$$EnhancerBySpringCGLIB$$7c4704f8$$FastClassBySpringCGLIB$$e0a4d3c3.invoke() ~[spring-boot-autoconfigure-1.5.9.RELEASE.jar:1.5.9.RELEASE] at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-4.3.13.RELEASE.jar:4.3.13.RELEASE] at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE] at org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration$$EnhancerBySpringCGLIB$$7c4704f8.mongoTemplate() ~[spring-boot-autoconfigure-1.5.9.RELEASE.jar:1.5.9.RELEASE] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_151] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_151] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_151] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_151] at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE] ... 47 common frames omitted Caused by: com.mongodb.MongoCommandException: Command failed with error 2: 'Message: {"Errors":["Too many 'included' paths (106) specified in policy. A maximum of 100 is allowed."]} ActivityId: 25611363-0000-0000-0000-000000000000, Request URI: /apps/bbbd93b0-83ee-44a2-9015-ca7226457764/services/63c75889-e342-42b3-81b0-4851cae426d7/partitions/89ba02e8-b034-4b75-b8a0-57194d79f785/replicas/131587440168033880p, RequestStats: , SDK: Microsoft.Azure.Documents.Common/1.19.121.4' on server dz5prdddc02-docdb-1.documents.azure.com:10255. The full response is { "_t" : "OKMongoResponse", "ok" : 0, "code" : 2, "errmsg" : "Message: {\"Errors\":[\"Too many 'included' paths (106) specified in policy. A maximum of 100 is allowed.\"]}\r\nActivityId: 25611363-0000-0000-0000-000000000000, Request URI: /apps/bbbd93b0-83ee-44a2-9015-ca7226457764/services/63c75889-e342-42b3-81b0-4851cae426d7/partitions/89ba02e8-b034-4b75-b8a0-57194d79f785/replicas/131587440168033880p, RequestStats: , SDK: Microsoft.Azure.Documents.Common/1.19.121.4", "$err" : "Message: {\"Errors\":[\"Too many 'included' paths (106) specified in policy. A maximum of 100 is allowed.\"]}\r\nActivityId: 25611363-0000-0000-0000-000000000000, Request URI: /apps/bbbd93b0-83ee-44a2-9015-ca7226457764/services/63c75889-e342-42b3-81b0-4851cae426d7/partitions/89ba02e8-b034-4b75-b8a0-57194d79f785/replicas/131587440168033880p, RequestStats: , SDK: Microsoft.Azure.Documents.Common/1.19.121.4" } at com.mongodb.connection.ProtocolHelper.getCommandFailureException(ProtocolHelper.java:115) ~[mongodb-driver-core-3.4.3.jar:na] at com.mongodb.connection.CommandProtocol.execute(CommandProtocol.java:114) ~[mongodb-driver-core-3.4.3.jar:na] at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:168) ~[mongodb-driver-core-3.4.3.jar:na] at com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:289) ~[mongodb-driver-core-3.4.3.jar:na] at com.mongodb.connection.DefaultServerConnection.command(DefaultServerConnection.java:176) ~[mongodb-driver-core-3.4.3.jar:na] at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:216) ~[mongodb-driver-core-3.4.3.jar:na] at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:207) ~[mongodb-driver-core-3.4.3.jar:na] at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:146) ~[mongodb-driver-core-3.4.3.jar:na] at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:139) ~[mongodb-driver-core-3.4.3.jar:na] at com.mongodb.operation.CreateIndexesOperation$1.call(CreateIndexesOperation.java:150) ~[mongodb-driver-core-3.4.3.jar:na] at com.mongodb.operation.CreateIndexesOperation$1.call(CreateIndexesOperation.java:144) ~[mongodb-driver-core-3.4.3.jar:na] at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:426) ~[mongodb-driver-core-3.4.3.jar:na] at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:417) ~[mongodb-driver-core-3.4.3.jar:na] at com.mongodb.operation.CreateIndexesOperation.execute(CreateIndexesOperation.java:144) ~[mongodb-driver-core-3.4.3.jar:na] at com.mongodb.operation.CreateIndexesOperation.execute(CreateIndexesOperation.java:71) ~[mongodb-driver-core-3.4.3.jar:na] at com.mongodb.Mongo.execute(Mongo.java:845) ~[mongodb-driver-3.4.3.jar:na] at com.mongodb.Mongo$2.execute(Mongo.java:828) ~[mongodb-driver-3.4.3.jar:na] at com.mongodb.DBCollection.createIndex(DBCollection.java:1618) ~[mongodb-driver-3.4.3.jar:na] at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexCreator.createIndex(MongoPersistentEntityIndexCreator.java:142) ~[spring-data-mongodb-1.10.9.RELEASE.jar:na] ... 63 common frames omitted

1

1 Answers

2
votes

This error - “Too many 'included' paths (106) specified in policy. A maximum of 100 is allowed.” - occurs when you create created multiple indexes on the account and exceed the limit (100). However, you don’t have to create most of these indexes (if any) as, in contrast to MongoDB, CosmosDB automatically indexes all paths in the document, explicit indexes aren’t required. Try to exclude createIndex/ensureIndex commands and their Spring equivalents unless they have to do with creating unique indexes (you need createIndex for that as we don’t know which fields you want this constraint on).