You might encounter the following error suddenly:
java.lang.StackOverflowError
at java.lang.String.<init>(String.java:201)
at java.lang.String.substring(String.java:1956)
at sun.reflect.misc.ReflectUtil.isNonPublicProxyClass(ReflectUtil.java:288)
at sun.reflect.misc.ReflectUtil.checkPackageAccess(ReflectUtil.java:165)
at sun.reflect.misc.ReflectUtil.isPackageAccessible(ReflectUtil.java:195)
at java.beans.MethodRef.get(MethodRef.java:72)
at java.beans.PropertyDescriptor.getReadMethod(PropertyDescriptor.java:206)
at org.springframework.data.mapping.model.AbstractPersistentProperty.getGetter(AbstractPersistentProperty.java:159)
at org.springframework.data.mapping.model.BeanWrapper.getProperty(BeanWrapper.java:127)
at org.springframework.data.mapping.model.BeanWrapper.getProperty(BeanWrapper.java:100)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter$3.doWithPersistentProperty(MappingMongoConverter.java:419)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter$3.doWithPersistentProperty(MappingMongoConverter.java:412)
at org.springframework.data.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:307)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.writeInternal(MappingMongoConverter.java:412)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.writeInternal(MappingMongoConverter.java:386)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.writeCollectionInternal(MappingMongoConverter.java:622)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.createCollection(MappingMongoConverter.java:546)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.writePropertyInternal(MappingMongoConverter.java:457)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter$3.doWithPersistentProperty(MappingMongoConverter.java:424)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter$3.doWithPersistentProperty(MappingMongoConverter.java:412)
at org.springframework.data.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:307)
I didn't dig into the problem due to lack of time
but the culprit was `Logger` in a MongoDB document as follows:
private final Logger log = LoggerFactory.getLogger(getClass());
It could be fixed with `org.springframework.data.annotation.Transient` as follows:
@Transient
private final Logger log = LoggerFactory.getLogger(getClass());
but it doesn't make sense that every document has its own field for the logger
although the logger will be singleton.
Using `static` is much better as follows:
private static final Logger log = LoggerFactory.getLogger(NaboxImpressionLog.class);
Reference:
http://stackoverflow.com/questions/21734785/mongodb-spring-saving-an-object-causes-stackoverflowerror
No comments:
Post a Comment