java.lang.IllegalStateException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • Within a shared module our entity defines a unique index like this: {code} public class WorkflowDefinition extends AbstractDocument { @Nonnull @Indexed(unique = true) private final String name; // ... } {code} The problem starts on another project which is using this class and database. For ETL purposes this project is accessing an replication node with only read privileges. This ETL Application fails because it has no rights to create an indes: {code} java.lang.IllegalStateException: Failed to execute CommandLineRunner at org.springframework.boot.SpringApplication.runCommandLineRunners(SpringApplication.java:675) at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:690) at org.springframework.boot.SpringApplication.run(SpringApplication.java:321) at org.springframework.boot.SpringApplication.run(SpringApplication.java:957) at org.springframework.boot.SpringApplication.run(SpringApplication.java:946) at com...ExporterApplication.main(SqlExporterApplication.java:38) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140) Caused by: com.mongodb.CommandFailureException: { "serverUsed" : "productive-mon...mongodbdns.com:27000" , "ok" : 0.0 , "errmsg" : "not authorized on ... to execute command { createIndexes: \"workflowDefinition\", indexes: [ { name: \"name\", ns: \"ivi.workflowDefinition\", unique: true, key: { name: 1 } } ] }" , "code" : 13} at com.mongodb.CommandResult.getException(CommandResult.java:76) at com.mongodb.CommandResult.throwOnError(CommandResult.java:131) at com.mongodb.DBCollectionImpl.createIndex(DBCollectionImpl.java:362) at com.mongodb.DBCollection.createIndex(DBCollection.java:563) at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexCreator.createIndex(MongoPersistentEntityIndexCreator.java:136) at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexCreator.checkForAndCreateIndexes(MongoPersistentEntityIndexCreator.java:129) at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexCreator.checkForIndexes(MongoPersistentEntityIndexCreator.java:121) at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexCreator.onApplicationEvent(MongoPersistentEntityIndexCreator.java:105) at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexCreator.onApplicationEvent(MongoPersistentEntityIndexCreator.java:46) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:98) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:333) at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:306) at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.createAndRegisterProperty(AbstractMappingContext.java:469) at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.doWith(AbstractMappingContext.java:426) at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:604) at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:294) at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:180) at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:140) at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:67) at org.springframework.data.mongodb.core.MongoTemplate.determineCollectionName(MongoTemplate.java:1881) at org.springframework.data.mongodb.core.MongoTemplate.findOne(MongoTemplate.java:492) at com...ExporterApplication.run(SqlExporterApplication.java:53) at org.springframework.boot.SpringApplication.runCommandLineRunners(SpringApplication.java:672) ... 10 more {code}
    via by Christian Schneider,
  • Within a shared module our entity defines a unique index like this: {code} public class WorkflowDefinition extends AbstractDocument { @Nonnull @Indexed(unique = true) private final String name; // ... } {code} The problem starts on another project which is using this class and database. For ETL purposes this project is accessing an replication node with only read privileges. This ETL Application fails because it has no rights to create an indes: {code} java.lang.IllegalStateException: Failed to execute CommandLineRunner at org.springframework.boot.SpringApplication.runCommandLineRunners(SpringApplication.java:675) at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:690) at org.springframework.boot.SpringApplication.run(SpringApplication.java:321) at org.springframework.boot.SpringApplication.run(SpringApplication.java:957) at org.springframework.boot.SpringApplication.run(SpringApplication.java:946) at com...ExporterApplication.main(SqlExporterApplication.java:38) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140) Caused by: com.mongodb.CommandFailureException: { "serverUsed" : "productive-mon...mongodbdns.com:27000" , "ok" : 0.0 , "errmsg" : "not authorized on ... to execute command { createIndexes: \"workflowDefinition\", indexes: [ { name: \"name\", ns: \"ivi.workflowDefinition\", unique: true, key: { name: 1 } } ] }" , "code" : 13} at com.mongodb.CommandResult.getException(CommandResult.java:76) at com.mongodb.CommandResult.throwOnError(CommandResult.java:131) at com.mongodb.DBCollectionImpl.createIndex(DBCollectionImpl.java:362) at com.mongodb.DBCollection.createIndex(DBCollection.java:563) at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexCreator.createIndex(MongoPersistentEntityIndexCreator.java:136) at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexCreator.checkForAndCreateIndexes(MongoPersistentEntityIndexCreator.java:129) at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexCreator.checkForIndexes(MongoPersistentEntityIndexCreator.java:121) at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexCreator.onApplicationEvent(MongoPersistentEntityIndexCreator.java:105) at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexCreator.onApplicationEvent(MongoPersistentEntityIndexCreator.java:46) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:98) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:333) at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:306) at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.createAndRegisterProperty(AbstractMappingContext.java:469) at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.doWith(AbstractMappingContext.java:426) at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:604) at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:294) at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:180) at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:140) at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:67) at org.springframework.data.mongodb.core.MongoTemplate.determineCollectionName(MongoTemplate.java:1881) at org.springframework.data.mongodb.core.MongoTemplate.findOne(MongoTemplate.java:492) at com...ExporterApplication.run(SqlExporterApplication.java:53) at org.springframework.boot.SpringApplication.runCommandLineRunners(SpringApplication.java:672) ... 10 more {code}
    via by Christian Schneider,
  • When a {{MappingException}} occurs, the {{MongoTemplate.CloseableIterableCusorAdapter}} will run into an NPE and swallow the source {{MappingException}}. That makes the stack trace unusable. {{CloseableIterableCursorAdapter}} is used for the new {{java.util.Stream}} support. The source of this issue [here| https://github.com/spring-projects/spring-data-mongodb/blob/1.8.0.RELEASE/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java#L2395]. The {{MongoExceptionTranslator.translateExceptionIfPossible(...)}} returns {{null}} [in case of mapping exceptions|https://github.com/spring-projects/spring-data-mongodb/blob/1.8.0.RELEASE/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoExceptionTranslator.java#L107]. The stack trace (where the nice {{MappingException}} is swallowed): {noformat} Exception in thread "main" java.lang.IllegalStateException: Failed to execute CommandLineRunner at org.springframework.boot.SpringApplication.runCommandLineRunners(SpringApplication.java:676) at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:691) at org.springframework.boot.SpringApplication.run(SpringApplication.java:322) at org.springframework.boot.SpringApplication.run(SpringApplication.java:967) at org.springframework.boot.SpringApplication.run(SpringApplication.java:956) at com....ExtractorApplication.main(ExtractorApplication.java:25) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140) Caused by: java.lang.NullPointerException <---- That should be the Mapping Exception at org.springframework.data.mongodb.core.MongoTemplate$CloseableIterableCusorAdapter.next(MongoTemplate.java:2395) at java.util.Iterator.forEachRemaining(Iterator.java:116) at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580) at com......(XXX.java:48) at com.....ExtractorApplication.run(ExtractorApplication.java:37) at org.springframework.boot.SpringApplication.runCommandLineRunners(SpringApplication.java:673) ... 10 more {noformat}
    via by Christian Schneider,
  • When a {{MappingException}} occurs, the {{MongoTemplate.CloseableIterableCusorAdapter}} will run into an NPE and swallow the source {{MappingException}}. That makes the stack trace unusable. {{CloseableIterableCursorAdapter}} is used for the new {{java.util.Stream}} support. The source of this issue [here| https://github.com/spring-projects/spring-data-mongodb/blob/1.8.0.RELEASE/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java#L2395]. The {{MongoExceptionTranslator.translateExceptionIfPossible(...)}} returns {{null}} [in case of mapping exceptions|https://github.com/spring-projects/spring-data-mongodb/blob/1.8.0.RELEASE/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoExceptionTranslator.java#L107]. The stack trace (where the nice {{MappingException}} is swallowed): {noformat} Exception in thread "main" java.lang.IllegalStateException: Failed to execute CommandLineRunner at org.springframework.boot.SpringApplication.runCommandLineRunners(SpringApplication.java:676) at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:691) at org.springframework.boot.SpringApplication.run(SpringApplication.java:322) at org.springframework.boot.SpringApplication.run(SpringApplication.java:967) at org.springframework.boot.SpringApplication.run(SpringApplication.java:956) at com....ExtractorApplication.main(ExtractorApplication.java:25) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140) Caused by: java.lang.NullPointerException <---- That should be the Mapping Exception at org.springframework.data.mongodb.core.MongoTemplate$CloseableIterableCusorAdapter.next(MongoTemplate.java:2395) at java.util.Iterator.forEachRemaining(Iterator.java:116) at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580) at com......(XXX.java:48) at com.....ExtractorApplication.run(ExtractorApplication.java:37) at org.springframework.boot.SpringApplication.runCommandLineRunners(SpringApplication.java:673) ... 10 more {noformat}
    via by Christian Schneider,
    • java.lang.IllegalStateException: Failed to execute CommandLineRunner at org.springframework.boot.SpringApplication.runCommandLineRunners(SpringApplication.java:675) at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:690) at org.springframework.boot.SpringApplication.run(SpringApplication.java:321) at org.springframework.boot.SpringApplication.run(SpringApplication.java:957) at org.springframework.boot.SpringApplication.run(SpringApplication.java:946)

    Users with the same issue

    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    3 more bugmates