13

We are running an old version of Tomcat, and a new web application has caused a stack trace like this

Caused by: java.lang.StackOverflowError
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)
    at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269)

This has been mentioned at https://bz.apache.org/bugzilla/show_bug.cgi?id=53871, and later versions (like Tomcat 8) don't seem to be affected.

How can I fix this?

Phyxx
  • 15,730
  • 13
  • 73
  • 112
  • check this post https://stackoverflow.com/questions/17584495/unable-to-complete-the-scan-for-annotations-for-web-application-app-due-to-a/49650960#49650960 – Ardeshir Ayati Apr 04 '18 at 12:30

3 Answers3

24

Since upgrading Tomcat was not an option, I needed a way to work around this issue.

As it turns out Tomcat 7.0.47 has the same issue, but better reporting. When run locally the reporting showed me this:

Caused by: java.lang.IllegalStateException: Unable to complete the scan for 
annotations for web application [/api] 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.ASN1Boolean->org.bouncycastle.asn1.DERBoolean-
>org.bouncycastle.asn1.ASN1Boolean]

Once I found the offending jar file, I added it to the catalina.properties file like this:

org.apache.catalina.startup.ContextConfig.jarsToSkip=bcprov*.jar

This appears to have worked around the issue in the older version of Tomcat.

prayagupa
  • 30,204
  • 14
  • 155
  • 192
Phyxx
  • 15,730
  • 13
  • 73
  • 112
  • 1
    Thanks! I've been trying to fix this for a long time, and of all the fixes I've tried this is the only one that actually works. – Jonas Rosenqvist Nov 26 '15 at 10:50
  • I added bcp*jdk15on.jar to DefaultJarScanner.jarsToSkip too - see https://tomcat.apache.org/tomcat-7.0-doc/config/systemprops.html#JAR_Scanning – Sampisa Jul 28 '17 at 15:32
21

I run into the same issue with a legacy project I got on recently. I found better solution here: Avoid cyclic reference inheritance in grails

As it turned out I also had two bcprov-jdk on classpath. In my case these were:

bcprov-jdk15on
bcprov-jdk16

Since it is a multimodule Maven project, I used

mvn dependency:tree -Dverbose -Dincludes=org.bouncycastle

to find where they come from. Then I removed the jdk16 since the up to date one is the jdk15on and it works.

Community
  • 1
  • 1
Ondrej Burkert
  • 6,617
  • 2
  • 32
  • 27
5

I had the same problem. For Tomcat 8.* and above, the property name has changed to tomcat.util.scan.StandardJarScanFilter.jarsToSkip.

See: https://tomcat.apache.org/tomcat-8.5-doc/config/systemprops.html#JAR_Scanning

Inside Tomcat directory, edit conf/catalina.properties file, find tomcat.util.scan.StandardJarScanFilter.jarsToSkip property and add the offending jars to the bottom of the list.

e.g

tomcat.util.scan.StandardJarScanFilter.jarsToSkip=\
annotations-api.jar,\
ant-junit*.jar,\
ant-launcher.jar,\
ant.jar,\
...
xmlParserAPIs.jar,\
xom-*.jar,\
bcprov*.jar
Marcelo C.
  • 3,822
  • 2
  • 22
  • 11