2014-02-12 2 views
3

우리의 아키텍처는 Spring과 MongoDB를 결합합니다. 일반적으로 사용자 정의 객체를 저장/편집하고 읽는 데 문제가 없습니다. 최근에 우리는 다음과 같은 오류가MongoDB - Spring - 객체를 저장하면 StackOverflowError가 발생합니다.

 java.lang.StackOverflowError 
at java.util.Collections.emptyList(Collections.java:2959) 
at org.springframework.data.util.TypeDiscoverer.getTypeArguments(TypeDiscoverer.java:442) 
at org.springframework.data.util.ClassTypeInformation.getTypeArguments(ClassTypeInformation.java:40) 
at org.springframework.data.util.TypeDiscoverer.getActualType(TypeDiscoverer.java:288) 
at org.springframework.data.util.ClassTypeInformation.getActualType(ClassTypeInformation.java:40) 
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.addCustomTypeKeyIfNecessary(MappingMongoConverter.java:650) 

또는

 java.lang.StackOverflowError 
at sun.misc.Unsafe.getObject(Native Method) 
at sun.misc.Unsafe.getObject(Unsafe.java:231) 
at sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:19) 
at java.lang.reflect.Field.get(Field.java:358) 
at org.springframework.util.ReflectionUtils.getField(ReflectionUtils.java:118) 
at org.springframework.data.mapping.model.BeanWrapper.getProperty(BeanWrapper.java:133) 
at org.springframework.data.mongodb.core.convert.MappingMongoConverter$3.doWithPersistentProperty(MappingMongoConverter.java:382) 

나는 우리의 아키텍처를 결합하여 모든 주요 클래스를 추가 해요 전에 내가 궁금해지기 시작하는 몇 가지 수정을 실행 한 당신의 여부 이전에 이런 종류의 예외가 발생 했습니까? 내가

MongoDB를

에 데이터 객체의 로거를 사용할 때주의해야 다시

protected final Log logger = LogFactory.getLog(getClass()); 

작업이 시작 로거를 제거 할 때

답변

3

분명히 나는,

내 데이터 객체에 로거를 추가 할 수 없습니다 @Transient를 사용하면 MongoDB 드라이버에 로거 변수를 유지하지 말아야한다고 표시됩니다.

http://docs.spring.io/spring-data/data-document/docs/current/reference/html/#mapping-usage-annotations

+0

와우, 당신이 그것을 알아 냈기 때문에 기쁩니다. 로거를 비공개로 선언하면 도움이됩니까? –

+4

static (선호) 또는 transient (이유는?)로 표시하면 괜찮을 것입니다. 당신은 정말로 인스턴스 당 로거를 원하지 않습니다. – evanchooly

+0

나는 아직 성숙하지 않은 MongoDB 드라이버를 사용한다. 마지막 로거 변수를 유지하려고 시도 할 때 충격을 받았다. 나는 어딘가에서 내가 과도기를 사용하면 괜찮을 것이라고 읽었고, 나는 그것을 검증해야 할 것이다. – Uri

관련 문제