0

Im not necessarily sure if this entire application run failed message is caused by a few key errors or not but I really dont know which of these problems to address first. I had to re-install mongodb on my laptop, along with restarting the app and re-importing maven dependencies and then when I try to run my app Im getting this response.

2020-06-14 11:07:40.417  WARN 3748 --- [  restartedMain] .m.c.i.MongoPersistentEntityIndexCreator : Automatic index creation will be disabled by default as of Spring Data MongoDB 3.x.
    Please use 'MongoMappingContext#setAutoIndexCreation(boolean)' or override 'MongoConfigurationSupport#autoIndexCreation()' to be explicit.
    However, we recommend setting up indices manually in an application ready block. You may use index derivation there as well.

    > -----------------------------------------------------------------------------------------
    > @EventListener(ApplicationReadyEvent.class)
    > public void initIndicesAfterStartup() {
    >
    >     IndexOperations indexOps = mongoTemplate.indexOps(DomainType.class);
    >
    >     IndexResolver resolver = new MongoPersistentEntityIndexResolver(mongoMappingContext);
    >     resolver.resolveIndexFor(DomainType.class).forEach(indexOps::ensureIndex);
    > }
    > -----------------------------------------------------------------------------------------

2020-06-14 11:07:40.454  INFO 3748 --- [  restartedMain] org.mongodb.driver.connection            : Opened connection [connectionId{localValue:2, serverValue:7}] to localhost:27017
2020-06-14 11:07:40.495  WARN 3748 --- [  restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authController': Unsatisfied dependency expressed through field 'userService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'customUserDetailsService': Unsatisfied dependency expressed through field 'userRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Cannot resolve reference to bean 'mongoTemplate' while setting bean property 'mongoOperations'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoTemplate' defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDbFactoryDependentConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.mongodb.core.MongoTemplate]: Factory method 'mongoTemplate' threw exception; nested exception is org.springframework.data.mongodb.UncategorizedMongoDbException: Command failed with error 197 (InvalidIndexSpecificationOption): 'The field 'unique' is not valid for an _id index specification. Specification: { v: 2, key: { _id: -1 }, name: "_id", ns: "Labmonsterz.User", unique: true }' on server localhost:27017. The full response is {"ok": 0.0, "errmsg": "The field 'unique' is not valid for an _id index specification. Specification: { v: 2, key: { _id: -1 }, name: \"_id\", ns: \"Labmonsterz.User\", unique: true }", "code": 197, "codeName": "InvalidIndexSpecificationOption"}; nested exception is com.mongodb.MongoCommandException: Command failed with error 197 (InvalidIndexSpecificationOption): 'The field 'unique' is not valid for an _id index specification. Specification: { v: 2, key: { _id: -1 }, name: "_id", ns: "Labmonsterz.User", unique: true }' on server localhost:27017. The full response is {"ok": 0.0, "errmsg": "The field 'unique' is not valid for an _id index specification. Specification: { v: 2, key: { _id: -1 }, name: \"_id\", ns: \"Labmonsterz.User\", unique: true }", "code": 197, "codeName": "InvalidIndexSpecificationOption"}
2020-06-14 11:07:40.497  INFO 3748 --- [  restartedMain] org.mongodb.driver.connection            : Closed connection [connectionId{localValue:2, serverValue:7}] to localhost:27017 because the pool has been closed.
2020-06-14 11:07:40.501  INFO 3748 --- [  restartedMain] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2020-06-14 11:07:40.512  INFO 3748 --- [  restartedMain] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-06-14 11:07:40.518 ERROR 3748 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authController': Unsatisfied dependency expressed through field 'userService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'customUserDetailsService': Unsatisfied dependency expressed through field 'userRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Cannot resolve reference to bean 'mongoTemplate' while setting bean property 'mongoOperations'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoTemplate' defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDbFactoryDependentConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.mongodb.core.MongoTemplate]: Factory method 'mongoTemplate' threw exception; nested exception is org.springframework.data.mongodb.UncategorizedMongoDbException: Command failed with error 197 (InvalidIndexSpecificationOption): 'The field 'unique' is not valid for an _id index specification. Specification: { v: 2, key: { _id: -1 }, name: "_id", ns: "Labmonsterz.User", unique: true }' on server localhost:27017. The full response is {"ok": 0.0, "errmsg": "The field 'unique' is not valid for an _id index specification. Specification: { v: 2, key: { _id: -1 }, name: \"_id\", ns: \"Labmonsterz.User\", unique: true }", "code": 197, "codeName": "InvalidIndexSpecificationOption"}; nested exception is com.mongodb.MongoCommandException: Command failed with error 197 (InvalidIndexSpecificationOption): 'The field 'unique' is not valid for an _id index specification. Specification: { v: 2, key: { _id: -1 }, name: "_id", ns: "Labmonsterz.User", unique: true }' on server localhost:27017. The full response is {"ok": 0.0, "errmsg": "The field 'unique' is not valid for an _id index specification. Specification: { v: 2, key: { _id: -1 }, name: \"_id\", ns: \"Labmonsterz.User\", unique: true }", "code": 197, "codeName": "InvalidIndexSpecificationOption"}
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:643) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:130) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1422) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:882) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878) ~[spring-context-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
    at com.labmonsterz.labmonsterz.LabmonsterzApplication.main(LabmonsterzApplication.java:10) [classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_211]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_211]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_211]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_211]
    at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.2.6.RELEASE.jar:2.2.6.RELEASE]
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'customUserDetailsService': Unsatisfied dependency expressed through field 'userRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Cannot resolve reference to bean 'mongoTemplate' while setting bean property 'mongoOperations'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoTemplate' defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDbFactoryDependentConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.mongodb.core.MongoTemplate]: Factory method 'mongoTemplate' threw exception; nested exception is org.springframework.data.mongodb.UncategorizedMongoDbException: Command failed with error 197 (InvalidIndexSpecificationOption): 'The field 'unique' is not valid for an _id index specification. Specification: { v: 2, key: { _id: -1 }, name: "_id", ns: "Labmonsterz.User", unique: true }' on server localhost:27017. The full response is {"ok": 0.0, "errmsg": "The field 'unique' is not valid for an _id index specification. Specification: { v: 2, key: { _id: -1 }, name: \"_id\", ns: \"Labmonsterz.User\", unique: true }", "code": 197, "codeName": "InvalidIndexSpecificationOption"}; nested exception is com.mongodb.MongoCommandException: Command failed with error 197 (InvalidIndexSpecificationOption): 'The field 'unique' is not valid for an _id index specification. Specification: { v: 2, key: { _id: -1 }, name: "_id", ns: "Labmonsterz.User", unique: true }' on server localhost:27017. The full response is {"ok": 0.0, "errmsg": "The field 'unique' is not valid for an _id index specification. Specification: { v: 2, key: { _id: -1 }, name: \"_id\", ns: \"Labmonsterz.User\", unique: true }", "code": 197, "codeName": "InvalidIndexSpecificationOption"}
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:643) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:130) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1422) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1290) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1210) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    ... 24 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Cannot resolve reference to bean 'mongoTemplate' while setting bean property 'mongoOperations'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoTemplate' defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDbFactoryDependentConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.mongodb.core.MongoTemplate]: Factory method 'mongoTemplate' threw exception; nested exception is org.springframework.data.mongodb.UncategorizedMongoDbException: Command failed with error 197 (InvalidIndexSpecificationOption): 'The field 'unique' is not valid for an _id index specification. Specification: { v: 2, key: { _id: -1 }, name: "_id", ns: "Labmonsterz.User", unique: true }' on server localhost:27017. The full response is {"ok": 0.0, "errmsg": "The field 'unique' is not valid for an _id index specification. Specification: { v: 2, key: { _id: -1 }, name: \"_id\", ns: \"Labmonsterz.User\", unique: true }", "code": 197, "codeName": "InvalidIndexSpecificationOption"}; nested exception is com.mongodb.MongoCommandException: Command failed with error 197 (InvalidIndexSpecificationOption): 'The field 'unique' is not valid for an _id index specification. Specification: { v: 2, key: { _id: -1 }, name: "_id", ns: "Labmonsterz.User", unique: true }' on server localhost:27017. The full response is {"ok": 0.0, "errmsg": "The field 'unique' is not valid for an _id index specification. Specification: { v: 2, key: { _id: -1 }, name: \"_id\", ns: \"Labmonsterz.User\", unique: true }", "code": 197, "codeName": "InvalidIndexSpecificationOption"}
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:342) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:113) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1699) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1444) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1290) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1210) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    ... 37 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoTemplate' defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDbFactoryDependentConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.mongodb.core.MongoTemplate]: Factory method 'mongoTemplate' threw exception; nested exception is org.springframework.data.mongodb.UncategorizedMongoDbException: Command failed with error 197 (InvalidIndexSpecificationOption): 'The field 'unique' is not valid for an _id index specification. Specification: { v: 2, key: { _id: -1 }, name: "_id", ns: "Labmonsterz.User", unique: true }' on server localhost:27017. The full response is {"ok": 0.0, "errmsg": "The field 'unique' is not valid for an _id index specification. Specification: { v: 2, key: { _id: -1 }, name: \"_id\", ns: \"Labmonsterz.User\", unique: true }", "code": 197, "codeName": "InvalidIndexSpecificationOption"}; nested exception is com.mongodb.MongoCommandException: Command failed with error 197 (InvalidIndexSpecificationOption): 'The field 'unique' is not valid for an _id index specification. Specification: { v: 2, key: { _id: -1 }, name: "_id", ns: "Labmonsterz.User", unique: true }' on server localhost:27017. The full response is {"ok": 0.0, "errmsg": "The field 'unique' is not valid for an _id index specification. Specification: { v: 2, key: { _id: -1 }, name: \"_id\", ns: \"Labmonsterz.User\", unique: true }", "code": 197, "codeName": "InvalidIndexSpecificationOption"}
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:656) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:636) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1338) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:330) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    ... 50 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.mongodb.core.MongoTemplate]: Factory method 'mongoTemplate' threw exception; nested exception is org.springframework.data.mongodb.UncategorizedMongoDbException: Command failed with error 197 (InvalidIndexSpecificationOption): 'The field 'unique' is not valid for an _id index specification. Specification: { v: 2, key: { _id: -1 }, name: "_id", ns: "Labmonsterz.User", unique: true }' on server localhost:27017. The full response is {"ok": 0.0, "errmsg": "The field 'unique' is not valid for an _id index specification. Specification: { v: 2, key: { _id: -1 }, name: \"_id\", ns: \"Labmonsterz.User\", unique: true }", "code": 197, "codeName": "InvalidIndexSpecificationOption"}; nested exception is com.mongodb.MongoCommandException: Command failed with error 197 (InvalidIndexSpecificationOption): 'The field 'unique' is not valid for an _id index specification. Specification: { v: 2, key: { _id: -1 }, name: "_id", ns: "Labmonsterz.User", unique: true }' on server localhost:27017. The full response is {"ok": 0.0, "errmsg": "The field 'unique' is not valid for an _id index specification. Specification: { v: 2, key: { _id: -1 }, name: \"_id\", ns: \"Labmonsterz.User\", unique: true }", "code": 197, "codeName": "InvalidIndexSpecificationOption"}
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:651) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    ... 60 common frames omitted

Process finished with exit code 0
package com.labmonsterz.labmonsterz.Entity;

import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.IndexDirection;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.DBRef;
import org.springframework.data.mongodb.core.mapping.Document;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;

@Document(collection = "User")
public class User {
    @Id
    @Indexed(unique = true, direction = IndexDirection.DESCENDING,  dropDups = true)
    private long id;
    private String uname;
    private String password;
    private String title;
    private String permissions = "";
    private boolean active;

    @DBRef
    private Set<Role> roles;

    public User(String uname,String password,String title, Set<Role> roles, String permissions){
        this.title = title;
        this.uname = uname;
        this.roles= roles;
        this.permissions = permissions;
        this.active = true;
    }

    protected User(){}

    public long getId() {
        return id;
    }
    public String getUname() {
        return uname;
    }

    public String getPassword() {
        return password;
    }

    public String getTitle() {
        return title;
    }

    public Set<Role> getRoles() {
        return roles;
    }

    public String getPermissions() {
        return permissions;
    }

    public boolean isActive() {
        return active;
    }

    public void setId(long id) {
        this.id = id;
    }

    public void setUname(String uname) {
        this.uname = uname;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public void setPermissions(String permissions) {
        this.permissions = permissions;
    }

    public void setActive(boolean active) {
        this.active = active;
    }

    public void setRoles(Set<Role> roles) {
        this.roles = roles;
    }
}
  • Your logs are not complete. Can you put full logs? – muasif80 Jun 14 '20 at 15:13
  • see this https://stackoverflow.com/questions/30675899/spring-security-noclassdeffounderror/30676129, you need to add Spring-security-web to your dependency – Tashkhisi Jun 14 '20 at 15:21
  • add this to your dependency org.springframework.security spring-security-web 4.0.1.RELEASE – Tashkhisi Jun 14 '20 at 15:34
  • Thanks for your time, I'm about to update my question with the response I'm getting now, I've added spring security web, but I'm still receiving errors. – Daniel Still Jun 14 '20 at 16:12
  • after adding spring security web, Im receiving the following errors still, My biggest question is, is this all stemming from one dependancy issue or not? – Daniel Still Jun 14 '20 at 16:51
  • 1
    can you also add the code of UserRepository and Entity here? – Arjit Jun 14 '20 at 19:20
  • check user repository, there may be some typos or syntax error in queries – jNambiar Jun 15 '20 at 05:06
  • I'm about to check their now, I'm starting to try and track each of these problems individually, considering how cumbersome taking on this entire log can be, my apologies. I'll post edits as I try to tackle the problem. – Daniel Still Jun 15 '20 at 05:24

0 Answers0