You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2013/02/19 17:20:33 UTC

svn commit: r1447791 - in /tomcat/trunk/java/org/apache/catalina/startup: ContextConfig.java LocalStrings.properties

Author: markt
Date: Tue Feb 19 16:20:32 2013
New Revision: 1447791

URL: http://svn.apache.org/r1447791
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=53871
Add the class hierarchy that triggered the StackOverflowError to the error message to aid debugging.

Modified:
    tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java
    tomcat/trunk/java/org/apache/catalina/startup/LocalStrings.properties

Modified: tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java?rev=1447791&r1=1447790&r2=1447791&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java Tue Feb 19 16:20:32 2013
@@ -1958,13 +1958,7 @@ public class ContextConfig implements Li
 
         ClassParser parser = new ClassParser(is, null);
         JavaClass clazz = parser.parse();
-        try {
-            checkHandlesTypes(clazz);
-        } catch (StackOverflowError soe) {
-            throw new IllegalStateException(sm.getString(
-                    "contextConfig.annotationsStackOverflow",
-                    context.getName()), soe);
-        }
+        checkHandlesTypes(clazz);
 
         if (handlesTypesOnly) {
             return;
@@ -2015,7 +2009,14 @@ public class ContextConfig implements Li
             populateJavaClassCache(className, javaClass);
             JavaClassCacheEntry entry = javaClassCache.get(className);
             if (entry.getSciSet() == null) {
-                populateSCIsForCacheEntry(entry);
+                try {
+                    populateSCIsForCacheEntry(entry);
+                } catch (StackOverflowError soe) {
+                    throw new IllegalStateException(sm.getString(
+                            "contextConfig.annotationsStackOverflow",
+                            context.getName(),
+                            classHierarchyToString(className, entry)));
+                }
             }
             if (entry.getSciSet().size() > 0) {
                 // Need to try and load the class
@@ -2067,6 +2068,30 @@ public class ContextConfig implements Li
     }
 
 
+    private String classHierarchyToString(String className,
+            JavaClassCacheEntry entry) {
+        JavaClassCacheEntry start = entry;
+        StringBuilder msg = new StringBuilder(className);
+        msg.append("->");
+
+        String parentName = entry.getSuperclassName();
+        JavaClassCacheEntry parent = javaClassCache.get(parentName);
+        int count = 0;
+
+        while (count < 100 && parent != null && parent != start) {
+            msg.append(parentName);
+            msg.append("->");
+
+            count ++;
+            parentName = parent.getSuperclassName();
+            parent = javaClassCache.get(parentName);
+        }
+
+        msg.append(parentName);
+
+        return msg.toString();
+    }
+
     private void populateJavaClassCache(String className, JavaClass javaClass) {
         if (javaClassCache.containsKey(className)) {
             return;

Modified: tomcat/trunk/java/org/apache/catalina/startup/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/LocalStrings.properties?rev=1447791&r1=1447790&r2=1447791&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/LocalStrings.properties Tue Feb 19 16:20:32 2013
@@ -18,7 +18,7 @@ catalina.noCluster=Cluster RuleSet not f
 catalina.shutdownHookFail=The shutdown hook experienced an error while trying to stop the server
 catalina.stopServer=No shutdown port configured. Shut down server through OS signal. Server not shut down.
 contextConfig.altDDNotFound=alt-dd file {0} not found
-contextConfig.annotationsStackOverflow=Unable to complete the scan for annotations for web application [{0}]. Possible root causes include a too low setting for -Xss and illegal cyclic inheritance dependencies
+contextConfig.annotationsStackOverflow=Unable to complete the scan for annotations for web application [{0}] 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 [{1}]
 contextConfig.applicationUrl=Unable to determine URL for application web.xml
 contextConfig.applicationMissing=Missing application web.xml, using defaults only
 contextConfig.applicationParse=Parse error in application web.xml file at {0}



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org