StackOverflow Error With Bytecode Enhancement


#1

Hi All…first post here. I am enabling the bytecode enhancement via the Maven plugin. I did the build and it did enhance all the @Entity classes, but when I start the application…I get this:

Caused by: java.lang.StackOverflowError: null
        at org.springframework.util.ConcurrentReferenceHashMap$Segment.getReference(ConcurrentReferenceHashMap.java:494)
        at org.springframework.util.ConcurrentReferenceHashMap.getReference(ConcurrentReferenceHashMap.java:264)
        at org.springframework.util.ConcurrentReferenceHashMap.getEntryIfAvailable(ConcurrentReferenceHashMap.java:250)
        at org.springframework.util.ConcurrentReferenceHashMap.get(ConcurrentReferenceHashMap.java:231)
        at org.springframework.util.ReflectionUtils.getDeclaredFields(ReflectionUtils.java:750)
        at org.springframework.util.ReflectionUtils.findField(ReflectionUtils.java:100)
        at org.springframework.util.ReflectionUtils.findField(ReflectionUtils.java:82)
        at org.springframework.data.util.TypeDiscoverer.getPropertyInformation(TypeDiscoverer.java:235)
        at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
        at org.springframework.data.util.TypeDiscoverer.getProperty(TypeDiscoverer.java:210)
        at org.springframework.data.util.ParentTypeAwareTypeInformation.getProperty(ParentTypeAwareTypeInformation.java:29)
        at org.springframework.data.util.TypeInformation.getRequiredProperty(TypeInformation.java:62)
        at org.springframework.data.mapping.model.Property.lambda$new$1(Property.java:63)
        at java.util.Optional.map(Optional.java:215)
        at org.springframework.data.mapping.model.Property.lambda$withFieldOrDescriptor$10(Property.java:252)
        at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
        at java.util.Spliterators$IteratorSpliterator.tryAdvance(Spliterators.java:1812)
        at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
        at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
        at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
        at org.springframework.data.util.Optionals.firstNonEmpty(Optionals.java:128)
        at org.springframework.data.util.Optionals.firstNonEmpty(Optionals.java:112)
        at org.springframework.data.mapping.model.Property.withFieldOrDescriptor(Property.java:250)
        at org.springframework.data.mapping.model.Property.<init>(Property.java:61)
        at org.springframework.data.mapping.model.Property.of(Property.java:121)
        at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.lambda$addPropertiesForRemainingDescriptors$2(AbstractMappingContext.java:545)
        at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
        at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
        at java.util.HashMap$ValueSpliterator.forEachRemaining(HashMap.java:1625)
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
        at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
        at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
        at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.addPropertiesForRemainingDescriptors(AbstractMappingContext.java:547)
        at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:399)
        at java.util.Collections$SingletonSet.forEach(Collections.java:4767)
        at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.createAndRegisterProperty(AbstractMappingContext.java:572)
        at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
        at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
        at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
        at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
        at java.util.HashMap$ValueSpliterator.forEachRemaining(HashMap.java:1625)
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
        at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
        at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
        at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.addPropertiesForRemainingDescriptors(AbstractMappingContext.java:547)
        at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:399)
        at java.util.Collections$SingletonSet.forEach(Collections.java:4767)
        at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.createAndRegisterProperty(AbstractMappingContext.java:572)

I have tried everything I know to try. I even stepped through all the hibernate code.

Using Spring Boot 2.0.4/ Hibernate 5.2.17/ Elasticsearch 5.6.10…basically all the dependencies from Spring Boot 2.0.4.

Any pointers would be greatly appreciated. Thanks in advance


#2

There’s no org.hibernate method call on the StackTrace, hence this is not a Hibernate problem but a Spring one.

Try to debug it and see what’s causing it.


#3

Hey Vlad…really appreciate you responding. I was thinking maybe the bytecode enhancement was not compatible but we are using Spring Boot and it’s dependencies. Would think that the bytecode enhancement would work. I have debugged it for a couple of days…but that AbstractMappingContext is really hard to debug as it uses streams pretty heavily. Do you know of anything else I can try?


#4

You should ask the question on the Spring forum since this is not related to Hibernate.