Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Cycle found" false positive [DATAMONGO-1121] #2037

Closed
spring-projects-issues opened this issue Dec 16, 2014 · 8 comments
Closed

"Cycle found" false positive [DATAMONGO-1121] #2037

spring-projects-issues opened this issue Dec 16, 2014 · 8 comments

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Dec 16, 2014

Max Alexejev opened DATAMONGO-1121 and commented

@Document(collection = "normalized_profiles")
public class NormalizedProfile {

    @Id
    private ObjectId id = ObjectId.get();
...
    private ListField<String> firstName;
    private ListField<String> firstNameCanonical;
...
}

So I have 2 properties - firstName and firstNameCanonical, and CycleChecker warns about possible cycle reference on framework startup. Quite misleading, because searchResults.profile.lastNameCanonical is not a subpath of searchResults.profile.lastName (for example).

I believe the problem is with following code in MongoPersistentEntityIndexResolver.Path.cycles():

/**
 * Checks whether the given property is owned by the same entity and if it has been already visited by a subset of
 * the current path. Given {@literal foo.bar.bar} cycles if {@literal foo.bar} has already been visited and
 * {@code class Bar} contains a property of type {@code Bar}. The previously mentioned path would not cycle if
 * {@code class Bar} contained a property of type {@code SomeEntity} named {@literal bar}.
 * 
 * @param property
 * @param path
 * @return
 */
boolean cycles(MongoPersistentProperty property, String path) {

    if (!property.getOwner().equals(this.property.getOwner())) {
        return false;
    }

    return path.contains(this.path);
}

'Contains' should be analyzed in terms of dot-notation (ie properties), rather than a simple string contains.

Full stacktrace:

2014-12-16 22:26:35.419 / [main] WARN  o.s.d.m.c.index.MongoPersistentEntityIndexResolver - Found cycle for field 'data' in type 'ListField' for path 'searchResults.profile.lastName'
org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexResolver$CyclicPropertyReferenceException: Found cycle for field 'data' in type 'ListField' for path 'searchResults.profile.lastName'
	at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexResolver$CycleGuard.protect(MongoPersistentEntityIndexResolver.java:472) ~[spring-data-mongodb-1.6.1.RELEASE.jar:na]
	at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexResolver$3.doWithPersistentProperty(MongoPersistentEntityIndexResolver.java:231) [spring-data-mongodb-1.6.1.RELEASE.jar:na]
	at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexResolver$3.doWithPersistentProperty(MongoPersistentEntityIndexResolver.java:226) [spring-data-mongodb-1.6.1.RELEASE.jar:na]
	at org.springframework.data.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:294) [spring-data-commons-1.9.1.RELEASE.jar:na]
	at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexResolver.appendTextIndexInformation(MongoPersistentEntityIndexResolver.java:226) [spring-data-mongodb-1.6.1.RELEASE.jar:na]
	at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexResolver.access$400(MongoPersistentEntityIndexResolver.java:56) [spring-data-mongodb-1.6.1.RELEASE.jar:na]
	at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexResolver$3.doWithPersistentProperty(MongoPersistentEntityIndexResolver.java:256) [spring-data-mongodb-1.6.1.RELEASE.jar:na]
	at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexResolver$3.doWithPersistentProperty(MongoPersistentEntityIndexResolver.java:226) [spring-data-mongodb-1.6.1.RELEASE.jar:na]
	at org.springframework.data.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:294) [spring-data-commons-1.9.1.RELEASE.jar:na]
	at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexResolver.appendTextIndexInformation(MongoPersistentEntityIndexResolver.java:226) [spring-data-mongodb-1.6.1.RELEASE.jar:na]
	at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexResolver.access$400(MongoPersistentEntityIndexResolver.java:56) [spring-data-mongodb-1.6.1.RELEASE.jar:na]
	at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexResolver$3.doWithPersistentProperty(MongoPersistentEntityIndexResolver.java:256) [spring-data-mongodb-1.6.1.RELEASE.jar:na]
	at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexResolver$3.doWithPersistentProperty(MongoPersistentEntityIndexResolver.java:226) [spring-data-mongodb-1.6.1.RELEASE.jar:na]
	at org.springframework.data.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:294) [spring-data-commons-1.9.1.RELEASE.jar:na]
	at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexResolver.appendTextIndexInformation(MongoPersistentEntityIndexResolver.java:226) [spring-data-mongodb-1.6.1.RELEASE.jar:na]
	at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexResolver.access$400(MongoPersistentEntityIndexResolver.java:56) [spring-data-mongodb-1.6.1.RELEASE.jar:na]
	at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexResolver$3.doWithPersistentProperty(MongoPersistentEntityIndexResolver.java:256) [spring-data-mongodb-1.6.1.RELEASE.jar:na]
	at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexResolver$3.doWithPersistentProperty(MongoPersistentEntityIndexResolver.java:226) [spring-data-mongodb-1.6.1.RELEASE.jar:na]
	at org.springframework.data.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:294) [spring-data-commons-1.9.1.RELEASE.jar:na]
	at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexResolver.appendTextIndexInformation(MongoPersistentEntityIndexResolver.java:226) [spring-data-mongodb-1.6.1.RELEASE.jar:na]
	at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexResolver.potentiallyCreateTextIndexDefinition(MongoPersistentEntityIndexResolver.java:205) [spring-data-mongodb-1.6.1.RELEASE.jar:na]
	at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexResolver.resolveIndexForEntity(MongoPersistentEntityIndexResolver.java:99) [spring-data-mongodb-1.6.1.RELEASE.jar:na]
	at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexResolver.resolveIndexForClass(MongoPersistentEntityIndexResolver.java:79) [spring-data-mongodb-1.6.1.RELEASE.jar:na]
	at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexResolver.resolveIndexForClass(MongoPersistentEntityIndexResolver.java:56) [spring-data-mongodb-1.6.1.RELEASE.jar:na]
	at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexCreator.checkForAndCreateIndexes(MongoPersistentEntityIndexCreator.java:128) [spring-data-mongodb-1.6.1.RELEASE.jar:na]
	at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexCreator.checkForIndexes(MongoPersistentEntityIndexCreator.java:121) [spring-data-mongodb-1.6.1.RELEASE.jar:na]
	at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexCreator.<init>(MongoPersistentEntityIndexCreator.java:87) [spring-data-mongodb-1.6.1.RELEASE.jar:na]
	at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexCreator.<init>(MongoPersistentEntityIndexCreator.java:64) [spring-data-mongodb-1.6.1.RELEASE.jar:na]
	at org.springframework.data.mongodb.core.MongoTemplate.<init>(MongoTemplate.java:218) [spring-data-mongodb-1.6.1.RELEASE.jar:na]
	at org.springframework.data.mongodb.config.AbstractMongoConfiguration.mongoTemplate(AbstractMongoConfiguration.java:95) [spring-data-mongodb-1.6.1.RELEASE.jar:na]
	at com.scorr.config.MongoStorageConfig$$EnhancerBySpringCGLIB$$486c2c56.CGLIB$mongoTemplate$8(<generated>) [spring-core-4.0.6.RELEASE.jar:na]
	at com.scorr.config.MongoStorageConfig$$EnhancerBySpringCGLIB$$486c2c56$$FastClassBySpringCGLIB$$8ad6efc3.invoke(<generated>) [spring-core-4.0.6.RELEASE.jar:na]
	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) [spring-core-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:312) [spring-context-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at com.scorr.config.MongoStorageConfig$$EnhancerBySpringCGLIB$$486c2c56.mongoTemplate(<generated>) [spring-core-4.0.6.RELEASE.jar:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_25]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_25]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_25]
	at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_25]
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:166) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:586) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1094) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:989) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1456) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1197) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:271) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1017) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:960) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:858) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:324) [spring-context-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at com.scorr.collector.CollectorWebConfig$$EnhancerBySpringCGLIB$$a7d50d23.userDetailsService(<generated>) [spring-core-4.0.6.RELEASE.jar:na]
	at com.scorr.collector.CollectorWebConfig.configureGlobal(CollectorWebConfig.java:79) [classes/:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_25]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_25]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_25]
	at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_25]
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:589) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760) [spring-context-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482) [spring-context-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403) [spring-web-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) [spring-web-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) [spring-web-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at com.scorr.web.EmbeddedWebServer$1.contextInitialized(EmbeddedWebServer.java:86) [classes/:na]
	at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:798) [jetty-server-9.2.4.v20141103.jar:9.2.4.v20141103]
	at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:444) [jetty-servlet-9.2.4.v20141103.jar:9.2.4.v20141103]
	at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:789) [jetty-server-9.2.4.v20141103.jar:9.2.4.v20141103]
	at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:294) [jetty-servlet-9.2.4.v20141103.jar:9.2.4.v20141103]
	at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1343) [jetty-webapp-9.2.4.v20141103.jar:9.2.4.v20141103]
	at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1336) [jetty-webapp-9.2.4.v20141103.jar:9.2.4.v20141103]
	at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:741) [jetty-server-9.2.4.v20141103.jar:9.2.4.v20141103]
	at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:499) [jetty-webapp-9.2.4.v20141103.jar:9.2.4.v20141103]
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) [jetty-util-9.2.4.v20141103.jar:9.2.4.v20141103]
	at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132) [jetty-util-9.2.4.v20141103.jar:9.2.4.v20141103]
	at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114) [jetty-util-9.2.4.v20141103.jar:9.2.4.v20141103]
	at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61) [jetty-server-9.2.4.v20141103.jar:9.2.4.v20141103]
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) [jetty-util-9.2.4.v20141103.jar:9.2.4.v20141103]
	at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132) [jetty-util-9.2.4.v20141103.jar:9.2.4.v20141103]
	at org.eclipse.jetty.server.Server.start(Server.java:387) [jetty-server-9.2.4.v20141103.jar:9.2.4.v20141103]
	at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114) [jetty-util-9.2.4.v20141103.jar:9.2.4.v20141103]
	at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61) [jetty-server-9.2.4.v20141103.jar:9.2.4.v20141103]
	at org.eclipse.jetty.server.Server.doStart(Server.java:354) [jetty-server-9.2.4.v20141103.jar:9.2.4.v20141103]
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) [jetty-util-9.2.4.v20141103.jar:9.2.4.v20141103]
	at com.scorr.web.EmbeddedWebServer.start(EmbeddedWebServer.java:106) [classes/:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_25]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_25]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_25]
	at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_25]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1681) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1620) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703) [spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760) [spring-context-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482) [spring-context-4.0.6.RELEASE.jar:4.0.6.RELEASE]
	at com.scorr.service.ServiceLauncher.main(ServiceLauncher.java:48) [classes/:na]

Affects: 1.6.1 (Evans SR1)

Issue Links:

  • DATAMONGO-1124 Switch log level for cyclic reference index warnings from WARN to INFO

  • DATAMONGO-1087 Incorrect warning for MongoPersistentEntityIndexResolver$CyclicPropertyReferenceException: Found cycle for field...

Referenced from: pull request #267

Backported to: 1.6.2 (Evans SR2), 1.5.5 (Dijkstra SR5)

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Dec 19, 2014

Christoph Strobl commented

Thanks Max Alexejev would you mind including the code for ListField in the sample above as the warning targets the data field within that type

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Dec 21, 2014

Max Alexejev commented

Hi Christoph!
ListField is just one of the classes who embed NormalizedProfile. I got exactly same log message for NormalizedProfile and all classes that embed it in any ways, just copied the wrong one. Sorry for that. NormalizedProfile code should be enough to reproduce issue

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jan 6, 2015

Christoph Strobl commented

So it looks like this NormalizedProfile.firstname -> ListField.<addPropertyNameHere> -> NormalizedProfile which would mean that the the CycleGurad works as expected. Or am I missing something?

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jan 16, 2015

Jan Philipp commented

I've also had the annoying log message already in 1.5, and in 1.6 it is a warning with stacktrace.

I really do not think I have a cycle.. but: I'm using the same type twice in a document: one for a selector, and another one for actual data

@Document
@CompoundIndexes({    @CompoundIndex(
        name = "index_by_user",
        def = "{\'user._id\' : 1, \'activity.published\' : 1}"
    ),     @CompoundIndex(
        name = "index_by_project",
        def = "{\'project._id\' : 1, \'user._id\' : 1, \'activity.published\' : 1}"
    )})
public class Envelope {
  @Id
  private String id;
  private User user; // POJO with property "id"
  private Project project; // POJO with property "id"
  private Activity activity;
}

public class Activity {
  /* several properties*/
  private Project project; // data content
}

Looking into the code where the exception is thrown, MongoPersistentEntityIndexResolver.CycleGuard#protect will be processed for Envelope.Project just as expected. Then Envelope.Acticity.Project will be processed for the same property key propertyTypeKey = "Project._id" which will fail finally. Because both have the same owner...

I do not understand why that both locations are treated as the same key...

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jan 16, 2015

Christoph Strobl commented

Jan Philipp any chance you can provide an example project that produces the warning?

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jan 16, 2015

Jan Philipp commented

Well, it took some time, but in https://github.com/knalli/poc_DATAMONGO_1121 you find an example.

I've configured logback showing only the significant messages:

01:08:16.306 [main]               DEBUG o.s.d.m.c.i.MongoPersistentEntityIndexCreator - Analyzing class class de.knallisworld.poc.mongo.model.Envelope for index information. 
01:08:16.318 [main]               WARN  o.s.d.m.c.i.MongoPersistentEntityIndexResolver - Found cycle for field '_id' in type 'Project' for path 'project' org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexResolver$CyclicPropertyReferenceException: Found cycle for field '_id' in type 'Project' for path 'project'
	at org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexResolver$CycleGuard.protect(MongoPersistentEntityIndexResolver.java:472)

The example uses an embedded MongoDB (which I found today, nice one). Just start the Main

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jan 19, 2015

Christoph Strobl commented

Thanks Jan Philipp that helped a lot! CycleGuard should only consider entity like properties when checking for potential cycles. Fixed that in issue/DATAMONGO-1121 branch. Artifacts for compile(group: 'org.springframework.data', name: 'spring-data-mongodb', version: '1.7.0.DATAMONGO-1121-SNAPSHOT' are already available in spring.io repository. If you've the time it would be great if you could verify this solves the issue you're facing

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jan 19, 2015

Jan Philipp commented

Yep, no more warnings regarding "cycle not found"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants