Avoid cyclic reference inheritance in grails
Asked Answered
C

2

8

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!

Chili answered 29/5, 2014 at 7:16 Comment(2)
There is another post on SO that refers to the same problem here: #17584995. I think you have the same problem - having two or more bouncycastle versions on the classpath. You should check grails dependency-report and exclude unwanted one.Osterhus
I got this same issue because I had bcprov-jdk15on-147.jar in my global lib folder and my application had bcprov-jdk15on-1.51.jar embedded in its lib folder, which caused this conflict in the class loader. After I removed the 1.47 from the global lib folder, my problem was resolved.Salgado
C
11

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.

Cassycast answered 20/7, 2015 at 21:1 Comment(1)
Nice, works like a charm. Since I take care of a multimodule Maven project, it helped me to search for where it comes from with: mvn dependency:tree -Dverbose -Dincludes=org.bouncycastleAthalie
S
0

In my case it was conflicting versions of org.bouncycastle:bcprov-jdk15on:jar:1.47 and org.bouncycastle:bcprov-jdk15on:jar:1.45. I discovered the root cause of the issue by running mvn dependency:tree in my Maven project. In version 1.45, DEREncodableVector is parent of ASN1EncodableVector, yet in 1.47 it's the other way around!!! Depending on which which JAR version loads each class first, you may get this issue, or if you get lucky then it doesn't happen, a probabilistic thing.

I solved issue by removing one of the transitive dependencies. I chose to remove the older one. This is how I did it in pom.xml:

...
 <dependency>
            <groupId>org.opensaml</groupId>
            <artifactId>xmltooling</artifactId>
            <version>1.3.2-1</version>
            <exclusions>
                <exclusion>
                    <artifactId>log4j-over-slf4j</artifactId>
                    <groupId>org.slf4j</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>jcl-over-slf4j</artifactId>
                    <groupId>org.slf4j</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>bcprov-jdk15</artifactId>
                    <groupId>org.bouncycastle</groupId>
                </exclusion>
            </exclusions>
...
Systematize answered 4/2, 2022 at 0:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.