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!

NiBE
  • 857
  • 2
  • 16
  • 39
  • There is another post on SO that refers to the same problem here: http://stackoverflow.com/questions/17584495/unable-to-complete-the-scan-for-annotations-for-web-application-app-due-to-a. 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. – lukelazarovic May 29 '14 at 07:54
  • 1
    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. – Pada Jan 02 '15 at 15:48

2 Answers2

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.

  • 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.bouncycastle – Ondrej Burkert Jun 24 '16 at 07:32
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>
...
Jose Quijada
  • 558
  • 6
  • 13