Bug 53266 - ServletContainerInitializer will crash catalina if dependcy is not present.
Summary: ServletContainerInitializer will crash catalina if dependcy is not present.
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 7.0.27
Hardware: PC All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-20 14:32 UTC by Kevin Rose
Modified: 2012-06-11 21:00 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin Rose 2012-05-20 14:32:34 UTC
When using a ServletContainerInitializer with a HandlesTypes annotation if any of the classes specified in the HandlesTypes annotation are not available due to a missing jar file catalina will crash with a "java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy".

Caused by: java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
	at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:653)
	at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:460)
	at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:286)
	at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:222)
	at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:69)
	at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:52)
	at java.lang.Class.initAnnotationsIfNecessary(Class.java:3070)
	at java.lang.Class.getAnnotation(Class.java:3029)
	at org.apache.catalina.startup.ContextConfig.processServletContainerInitializers(ContextConfig.java:1546)
	at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1222)
	at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:855)
	at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:345)
	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
	at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5161)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	... 7 more

Line where exception is thrown: "HandlesTypes ht = sci.getClass().getAnnotation(HandlesTypes.class);"
Comment 1 Christopher Schultz 2012-05-21 20:15:46 UTC
Would you expect anything else to happen?
Comment 2 Kevin Rose 2012-05-22 03:09:36 UTC
I would like to see tomcat gracefully shutdown with an error message prudent to the reason instead of an ArrayStoreException.

As it is possible for any library to contain a ServlerContainerInitializer if for any reason a need dependency in any library is missing this is possible to occur.
Comment 3 Mark Thomas 2012-06-11 21:00:24 UTC
Note the spec requires that the web application is permitted to start in this case.

This has been fixed in trunk and 7.0.x and will be included in 7.0.28 onwards.