Avoid cyclic reference inheritance in grails

NiBE picture NiBE · May 29, 2014 · Viewed 9.1k times · Source

I have a big project written in Grails 2.3.8. Sometimes when I deploy it using my CI I got this message:

Unable to complete the scan for annotations for web application [/ProjectName##1152] due to a StackOverflowError.

Possible root causes include a too low setting for -Xss and illegal cyclic inheritance dependencies. The class hierarchy being processed was [org.bouncycastle.asn1.ASN1EncodableVector->org.bouncycastle.asn1.DEREncodableVector->org.bouncycastle.asn1.ASN1EncodableVector]

I have already increased the Xss settings, but it's clear, but maybe I'm wrong, that there is a cyclic reference : org.bouncycastle.asn1.ASN1EncodableVector->org.bouncycastle.asn1.DEREncodableVector->org.bouncycastle.asn1.ASN1EncodableVector

I red that you can just avoid the checking, I cannot remove the library because I need it. But I have not idea how to do it in Grails. I can exclude them but it's not what I want.

thanks a lot for any advices

nibe

UPDATE I just fixed the issue. I remove every trace of bouncycastle library in the buildConfig file. No trace in dependecy or excludes. Just add the plug in crypto.2.0 and everything works fine!

Answer

Balaji Boggaram Ramanarayan picture Balaji Boggaram Ramanarayan · Jul 20, 2015

I think its because of two versions of JAR being referenced from classpath.

This is usually caused when different versions of bcprov-jdk*.jar being loaded.

For example, IN one of my scenario - I had 

..../webapps/FOO/WEB-INF/lib/bcprov-jdk15on-147.jar
..../webapps/FOO/WEB-INF/lib/bcprov-jdk15on-1.51.jar 

I got this resolved after removing any one of them from my classpath.