java.lang.StackOverflowError

Spring JIRA | Mark Dopheide | 5 years ago
  1. 0

    Retrieving a mongo entity from a roo jpa entity using @RelatedDocument fails. I've reproduced this using the milestone versions and nightly builds. I have this JPA entity {code} @RooJavaBean @RooToString @RooDisplayString @RooJpaActiveRecord public class JpaEntity { private String name; @RelatedDocument MongoEntity mongoEntity; } {code} and this Mongo entity {code} @RooJavaBean @RooToString @RooMongoEntity @RooDisplayString public class MongoEntity { private String name; } {code} and this in my applicationContext-mongo file {code:xml} <!-- Mongo cross-store aspect config --> <bean class="org.springframework.data.mongodb.crossstore.MongoDocumentBacking" factory-method="aspectOf"> <property name="changeSetPersister" ref="mongoChangeSetPersister" /> </bean> <bean id="mongoChangeSetPersister" class="org.springframework.data.mongodb.crossstore.MongoChangeSetPersister"> <property name="mongoTemplate" ref="mongoTemplate" /> <property name="entityManagerFactory" ref="entityManagerFactory" /> </bean> {code} I updated the pom with cross-store dependencies, etc. and setup the repository and controllers using {code} roo> repository mongo --interface ~.repository.MongoEntityRepository --entity ~.domain.MongoEntity roo> web mvc all --package ~.web {code} When I run this sample code: {code} @Override public void onApplicationEvent(ContextRefreshedEvent event) { if (event instanceof ContextRefreshedEvent) { JpaEntity jpaEntity = new JpaEntity(); jpaEntity.setName("jpa"); MongoEntity mongoEntity = new MongoEntity(); mongoEntity.setName("mongo"); mongoRepository.save(mongoEntity); jpaEntity.setMongoEntity(mongoEntity); jpaEntity.persist(); List<JpaEntity> jpaList = JpaEntity.findAllJpaEntitys(); MongoEntity me = jpaList.get(0).getMongoEntity(); // stack overflow String name = jpaList.get(0).getName(); } } {code} It produces a stack overflow trying to retrieve the mongoEntity. {code} SEVERE: Servlet.service() for servlet jsp threw exception java.lang.StackOverflowError at java.util.AbstractMap.toString(AbstractMap.java:478) at java.lang.String.valueOf(String.java:2826) at java.lang.StringBuilder.append(StringBuilder.java:115) at org.springframework.data.crossstore.HashMapChangeSet.toString(HashMapChangeSet.java:47) at java.lang.String.valueOf(String.java:2826) at java.lang.StringBuilder.append(StringBuilder.java:115) at com.test2.domain.JpaEntity_Roo_JavaBean.mongoEntity_aroundBody1$advice(JpaEntity_Roo_JavaBean.aj:241) at com.test2.domain.JpaEntity_Roo_JavaBean.ajc$interMethod$com_test2_domain_JpaEntity_Roo_JavaBean$com_test2_domain_JpaEntity$getMongoEntity(JpaEntity_Roo_JavaBean.aj:19) at com.test2.domain.JpaEntity.getMongoEntity(JpaEntity.java:1) at com.test2.domain.JpaEntity_Roo_JavaBean.ajc$interMethodDispatch1$com_test2_domain_JpaEntity_Roo_JavaBean$com_test2_domain_JpaEntity$getMongoEntity(JpaEntity_Roo_JavaBean.aj) at com.test2.domain.JpaEntity_Roo_ToString.ajc$interMethod$com_test2_domain_JpaEntity_Roo_ToString$com_test2_domain_JpaEntity$toString(JpaEntity_Roo_ToString.aj:11) at com.test2.domain.JpaEntity.toString(JpaEntity.java:1) at java.lang.String.valueOf(String.java:2826) at java.lang.StringBuilder.append(StringBuilder.java:115) at org.springframework.data.mongodb.crossstore.MongoChangeSetPersister.getPersistentId(MongoChangeSetPersister.java:108) at org.springframework.data.mongodb.crossstore.MongoDocumentBacking.ajc$interMethod$org_springframework_data_mongodb_crossstore_MongoDocumentBacking$org_springframework_data_mongodb_crossstore_DocumentBacked$get_persistent_id(MongoDocumentBacking.aj:198) at com.test2.domain.JpaEntity.get_persistent_id(JpaEntity.java:1) at org.springframework.data.mongodb.crossstore.MongoDocumentBacking.ajc$interMethodDispatch1$org_springframework_data_mongodb_crossstore_MongoDocumentBacking$org_springframework_data_mongodb_crossstore_DocumentBacked$get_persistent_id(MongoDocumentBacking.aj) at com.test2.domain.JpaEntity_Roo_JavaBean.mongoEntity_aroundBody1$advice(JpaEntity_Roo_JavaBean.aj:245) at com.test2.domain.JpaEntity_Roo_JavaBean.ajc$interMethod$com_test2_domain_JpaEntity_Roo_JavaBean$com_test2_domain_JpaEntity$getMongoEntity(JpaEntity_Roo_JavaBean.aj:19) at com.test2.domain.JpaEntity.getMongoEntity(JpaEntity.java:1) at com.test2.domain.JpaEntity_Roo_JavaBean.ajc$interMethodDispatch1$com_test2_domain_JpaEntity_Roo_JavaBean$com_test2_domain_JpaEntity$getMongoEntity(JpaEntity_Roo_JavaBean.aj) at com.test2.domain.JpaEntity_Roo_ToString.ajc$interMethod$com_test2_domain_JpaEntity_Roo_ToString$com_test2_domain_JpaEntity$toString(JpaEntity_Roo_ToString.aj:11) at com.test2.domain.JpaEntity.toString(JpaEntity.java:1) at java.lang.String.valueOf(String.java:2826) at java.lang.StringBuilder.append(StringBuilder.java:115) at org.springframework.data.mongodb.crossstore.MongoChangeSetPersister.getPersistentId(MongoChangeSetPersister.java:108) at org.springframework.data.mongodb.crossstore.MongoDocumentBacking.ajc$interMethod$org_springframework_data_mongodb_crossstore_MongoDocumentBacking$org_springframework_data_mongodb_crossstore_DocumentBacked$get_persistent_id(MongoDocumentBacking.aj:198) at com.test2.domain.JpaEntity.get_persistent_id(JpaEntity.java:1) at org.springframework.data.mongodb.crossstore.MongoDocumentBacking.ajc$interMethodDispatch1$org_springframework_data_mongodb_crossstore_MongoDocumentBacking$org_springframework_data_mongodb_crossstore_DocumentBacked$get_persistent_id(MongoDocumentBacking.aj) at com.test2.domain.JpaEntity_Roo_JavaBean.mongoEntity_aroundBody1$advice(JpaEntity_Roo_JavaBean.aj:245) at com.test2.domain.JpaEntity_Roo_JavaBean.ajc$interMethod$com_test2_domain_JpaEntity_Roo_JavaBean$com_test2_domain_JpaEntity$getMongoEntity(JpaEntity_Roo_JavaBean.aj:19) at com.test2.domain.JpaEntity.getMongoEntity(JpaEntity.java:1) {code} Note that the app runs ok when I remove the @RelatedDocument MongoEntity mongoEntity; but of course I lose the needed relation.

    Spring JIRA | 5 years ago | Mark Dopheide
    java.lang.StackOverflowError
  2. 0

    Retrieving a mongo entity from a roo jpa entity using @RelatedDocument fails. I've reproduced this using the milestone versions and nightly builds. I have this JPA entity {code} @RooJavaBean @RooToString @RooDisplayString @RooJpaActiveRecord public class JpaEntity { private String name; @RelatedDocument MongoEntity mongoEntity; } {code} and this Mongo entity {code} @RooJavaBean @RooToString @RooMongoEntity @RooDisplayString public class MongoEntity { private String name; } {code} and this in my applicationContext-mongo file {code:xml} <!-- Mongo cross-store aspect config --> <bean class="org.springframework.data.mongodb.crossstore.MongoDocumentBacking" factory-method="aspectOf"> <property name="changeSetPersister" ref="mongoChangeSetPersister" /> </bean> <bean id="mongoChangeSetPersister" class="org.springframework.data.mongodb.crossstore.MongoChangeSetPersister"> <property name="mongoTemplate" ref="mongoTemplate" /> <property name="entityManagerFactory" ref="entityManagerFactory" /> </bean> {code} I updated the pom with cross-store dependencies, etc. and setup the repository and controllers using {code} roo> repository mongo --interface ~.repository.MongoEntityRepository --entity ~.domain.MongoEntity roo> web mvc all --package ~.web {code} When I run this sample code: {code} @Override public void onApplicationEvent(ContextRefreshedEvent event) { if (event instanceof ContextRefreshedEvent) { JpaEntity jpaEntity = new JpaEntity(); jpaEntity.setName("jpa"); MongoEntity mongoEntity = new MongoEntity(); mongoEntity.setName("mongo"); mongoRepository.save(mongoEntity); jpaEntity.setMongoEntity(mongoEntity); jpaEntity.persist(); List<JpaEntity> jpaList = JpaEntity.findAllJpaEntitys(); MongoEntity me = jpaList.get(0).getMongoEntity(); // stack overflow String name = jpaList.get(0).getName(); } } {code} It produces a stack overflow trying to retrieve the mongoEntity. {code} SEVERE: Servlet.service() for servlet jsp threw exception java.lang.StackOverflowError at java.util.AbstractMap.toString(AbstractMap.java:478) at java.lang.String.valueOf(String.java:2826) at java.lang.StringBuilder.append(StringBuilder.java:115) at org.springframework.data.crossstore.HashMapChangeSet.toString(HashMapChangeSet.java:47) at java.lang.String.valueOf(String.java:2826) at java.lang.StringBuilder.append(StringBuilder.java:115) at com.test2.domain.JpaEntity_Roo_JavaBean.mongoEntity_aroundBody1$advice(JpaEntity_Roo_JavaBean.aj:241) at com.test2.domain.JpaEntity_Roo_JavaBean.ajc$interMethod$com_test2_domain_JpaEntity_Roo_JavaBean$com_test2_domain_JpaEntity$getMongoEntity(JpaEntity_Roo_JavaBean.aj:19) at com.test2.domain.JpaEntity.getMongoEntity(JpaEntity.java:1) at com.test2.domain.JpaEntity_Roo_JavaBean.ajc$interMethodDispatch1$com_test2_domain_JpaEntity_Roo_JavaBean$com_test2_domain_JpaEntity$getMongoEntity(JpaEntity_Roo_JavaBean.aj) at com.test2.domain.JpaEntity_Roo_ToString.ajc$interMethod$com_test2_domain_JpaEntity_Roo_ToString$com_test2_domain_JpaEntity$toString(JpaEntity_Roo_ToString.aj:11) at com.test2.domain.JpaEntity.toString(JpaEntity.java:1) at java.lang.String.valueOf(String.java:2826) at java.lang.StringBuilder.append(StringBuilder.java:115) at org.springframework.data.mongodb.crossstore.MongoChangeSetPersister.getPersistentId(MongoChangeSetPersister.java:108) at org.springframework.data.mongodb.crossstore.MongoDocumentBacking.ajc$interMethod$org_springframework_data_mongodb_crossstore_MongoDocumentBacking$org_springframework_data_mongodb_crossstore_DocumentBacked$get_persistent_id(MongoDocumentBacking.aj:198) at com.test2.domain.JpaEntity.get_persistent_id(JpaEntity.java:1) at org.springframework.data.mongodb.crossstore.MongoDocumentBacking.ajc$interMethodDispatch1$org_springframework_data_mongodb_crossstore_MongoDocumentBacking$org_springframework_data_mongodb_crossstore_DocumentBacked$get_persistent_id(MongoDocumentBacking.aj) at com.test2.domain.JpaEntity_Roo_JavaBean.mongoEntity_aroundBody1$advice(JpaEntity_Roo_JavaBean.aj:245) at com.test2.domain.JpaEntity_Roo_JavaBean.ajc$interMethod$com_test2_domain_JpaEntity_Roo_JavaBean$com_test2_domain_JpaEntity$getMongoEntity(JpaEntity_Roo_JavaBean.aj:19) at com.test2.domain.JpaEntity.getMongoEntity(JpaEntity.java:1) at com.test2.domain.JpaEntity_Roo_JavaBean.ajc$interMethodDispatch1$com_test2_domain_JpaEntity_Roo_JavaBean$com_test2_domain_JpaEntity$getMongoEntity(JpaEntity_Roo_JavaBean.aj) at com.test2.domain.JpaEntity_Roo_ToString.ajc$interMethod$com_test2_domain_JpaEntity_Roo_ToString$com_test2_domain_JpaEntity$toString(JpaEntity_Roo_ToString.aj:11) at com.test2.domain.JpaEntity.toString(JpaEntity.java:1) at java.lang.String.valueOf(String.java:2826) at java.lang.StringBuilder.append(StringBuilder.java:115) at org.springframework.data.mongodb.crossstore.MongoChangeSetPersister.getPersistentId(MongoChangeSetPersister.java:108) at org.springframework.data.mongodb.crossstore.MongoDocumentBacking.ajc$interMethod$org_springframework_data_mongodb_crossstore_MongoDocumentBacking$org_springframework_data_mongodb_crossstore_DocumentBacked$get_persistent_id(MongoDocumentBacking.aj:198) at com.test2.domain.JpaEntity.get_persistent_id(JpaEntity.java:1) at org.springframework.data.mongodb.crossstore.MongoDocumentBacking.ajc$interMethodDispatch1$org_springframework_data_mongodb_crossstore_MongoDocumentBacking$org_springframework_data_mongodb_crossstore_DocumentBacked$get_persistent_id(MongoDocumentBacking.aj) at com.test2.domain.JpaEntity_Roo_JavaBean.mongoEntity_aroundBody1$advice(JpaEntity_Roo_JavaBean.aj:245) at com.test2.domain.JpaEntity_Roo_JavaBean.ajc$interMethod$com_test2_domain_JpaEntity_Roo_JavaBean$com_test2_domain_JpaEntity$getMongoEntity(JpaEntity_Roo_JavaBean.aj:19) at com.test2.domain.JpaEntity.getMongoEntity(JpaEntity.java:1) {code} Note that the app runs ok when I remove the @RelatedDocument MongoEntity mongoEntity; but of course I lose the needed relation.

    Spring JIRA | 5 years ago | Mark Dopheide
    java.lang.StackOverflowError
  3. 0

    StackOverflow in XmppUtils

    GitHub | 3 years ago | oxtoacart
    java.lang.StackOverflowError
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    can't load widgets containing long strings

    GitHub | 4 years ago | stevebhall
    java.lang.StackOverflowError
  6. 0

    Poor message for stack overflow errors

    GitHub | 2 years ago | ldcouto
    java.lang.StackOverflowError

  1. serious2monkeys 1 times, last 2 months ago
3 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.StackOverflowError

    No message provided

    at java.util.AbstractMap.toString()
  2. Java RT
    StringBuilder.append
    1. java.util.AbstractMap.toString(AbstractMap.java:478)
    2. java.lang.String.valueOf(String.java:2826)
    3. java.lang.StringBuilder.append(StringBuilder.java:115)
    3 frames
  3. Spring Data Core
    HashMapChangeSet.toString
    1. org.springframework.data.crossstore.HashMapChangeSet.toString(HashMapChangeSet.java:47)
    1 frame
  4. Java RT
    StringBuilder.append
    1. java.lang.String.valueOf(String.java:2826)
    2. java.lang.StringBuilder.append(StringBuilder.java:115)
    2 frames
  5. com.test2.domain
    JpaEntity.toString
    1. com.test2.domain.JpaEntity_Roo_JavaBean.mongoEntity_aroundBody1$advice(JpaEntity_Roo_JavaBean.aj:241)
    2. com.test2.domain.JpaEntity_Roo_JavaBean.ajc$interMethod$com_test2_domain_JpaEntity_Roo_JavaBean$com_test2_domain_JpaEntity$getMongoEntity(JpaEntity_Roo_JavaBean.aj:19)
    3. com.test2.domain.JpaEntity.getMongoEntity(JpaEntity.java:1)
    4. com.test2.domain.JpaEntity_Roo_JavaBean.ajc$interMethodDispatch1$com_test2_domain_JpaEntity_Roo_JavaBean$com_test2_domain_JpaEntity$getMongoEntity(JpaEntity_Roo_JavaBean.aj)
    5. com.test2.domain.JpaEntity_Roo_ToString.ajc$interMethod$com_test2_domain_JpaEntity_Roo_ToString$com_test2_domain_JpaEntity$toString(JpaEntity_Roo_ToString.aj:11)
    6. com.test2.domain.JpaEntity.toString(JpaEntity.java:1)
    6 frames
  6. Java RT
    StringBuilder.append
    1. java.lang.String.valueOf(String.java:2826)
    2. java.lang.StringBuilder.append(StringBuilder.java:115)
    2 frames
  7. Spring Data MongoDB - Cross-Store Support
    MongoDocumentBacking.ajc$interMethod$org_springframework_data_mongodb_crossstore_MongoDocumentBacking$org_springframework_data_mongodb_crossstore_DocumentBacked$get_persistent_id
    1. org.springframework.data.mongodb.crossstore.MongoChangeSetPersister.getPersistentId(MongoChangeSetPersister.java:108)
    2. org.springframework.data.mongodb.crossstore.MongoDocumentBacking.ajc$interMethod$org_springframework_data_mongodb_crossstore_MongoDocumentBacking$org_springframework_data_mongodb_crossstore_DocumentBacked$get_persistent_id(MongoDocumentBacking.aj:198)
    2 frames
  8. com.test2.domain
    JpaEntity.get_persistent_id
    1. com.test2.domain.JpaEntity.get_persistent_id(JpaEntity.java:1)
    1 frame
  9. Spring Data MongoDB - Cross-Store Support
    MongoDocumentBacking.ajc$interMethodDispatch1$org_springframework_data_mongodb_crossstore_MongoDocumentBacking$org_springframework_data_mongodb_crossstore_DocumentBacked$get_persistent_id
    1. org.springframework.data.mongodb.crossstore.MongoDocumentBacking.ajc$interMethodDispatch1$org_springframework_data_mongodb_crossstore_MongoDocumentBacking$org_springframework_data_mongodb_crossstore_DocumentBacked$get_persistent_id(MongoDocumentBacking.aj)
    1 frame
  10. com.test2.domain
    JpaEntity.toString
    1. com.test2.domain.JpaEntity_Roo_JavaBean.mongoEntity_aroundBody1$advice(JpaEntity_Roo_JavaBean.aj:245)
    2. com.test2.domain.JpaEntity_Roo_JavaBean.ajc$interMethod$com_test2_domain_JpaEntity_Roo_JavaBean$com_test2_domain_JpaEntity$getMongoEntity(JpaEntity_Roo_JavaBean.aj:19)
    3. com.test2.domain.JpaEntity.getMongoEntity(JpaEntity.java:1)
    4. com.test2.domain.JpaEntity_Roo_JavaBean.ajc$interMethodDispatch1$com_test2_domain_JpaEntity_Roo_JavaBean$com_test2_domain_JpaEntity$getMongoEntity(JpaEntity_Roo_JavaBean.aj)
    5. com.test2.domain.JpaEntity_Roo_ToString.ajc$interMethod$com_test2_domain_JpaEntity_Roo_ToString$com_test2_domain_JpaEntity$toString(JpaEntity_Roo_ToString.aj:11)
    6. com.test2.domain.JpaEntity.toString(JpaEntity.java:1)
    6 frames
  11. Java RT
    StringBuilder.append
    1. java.lang.String.valueOf(String.java:2826)
    2. java.lang.StringBuilder.append(StringBuilder.java:115)
    2 frames
  12. Spring Data MongoDB - Cross-Store Support
    MongoDocumentBacking.ajc$interMethod$org_springframework_data_mongodb_crossstore_MongoDocumentBacking$org_springframework_data_mongodb_crossstore_DocumentBacked$get_persistent_id
    1. org.springframework.data.mongodb.crossstore.MongoChangeSetPersister.getPersistentId(MongoChangeSetPersister.java:108)
    2. org.springframework.data.mongodb.crossstore.MongoDocumentBacking.ajc$interMethod$org_springframework_data_mongodb_crossstore_MongoDocumentBacking$org_springframework_data_mongodb_crossstore_DocumentBacked$get_persistent_id(MongoDocumentBacking.aj:198)
    2 frames
  13. com.test2.domain
    JpaEntity.get_persistent_id
    1. com.test2.domain.JpaEntity.get_persistent_id(JpaEntity.java:1)
    1 frame
  14. Spring Data MongoDB - Cross-Store Support
    MongoDocumentBacking.ajc$interMethodDispatch1$org_springframework_data_mongodb_crossstore_MongoDocumentBacking$org_springframework_data_mongodb_crossstore_DocumentBacked$get_persistent_id
    1. org.springframework.data.mongodb.crossstore.MongoDocumentBacking.ajc$interMethodDispatch1$org_springframework_data_mongodb_crossstore_MongoDocumentBacking$org_springframework_data_mongodb_crossstore_DocumentBacked$get_persistent_id(MongoDocumentBacking.aj)
    1 frame
  15. com.test2.domain
    JpaEntity.getMongoEntity
    1. com.test2.domain.JpaEntity_Roo_JavaBean.mongoEntity_aroundBody1$advice(JpaEntity_Roo_JavaBean.aj:245)
    2. com.test2.domain.JpaEntity_Roo_JavaBean.ajc$interMethod$com_test2_domain_JpaEntity_Roo_JavaBean$com_test2_domain_JpaEntity$getMongoEntity(JpaEntity_Roo_JavaBean.aj:19)
    3. com.test2.domain.JpaEntity.getMongoEntity(JpaEntity.java:1)
    3 frames