My Oracle Support Banner

ServletContainerInitializer Doesn't Find @HandlesTypes Classes Unless Directly Extended (Doc ID 1665019.1)

Last updated on JUNE 02, 2023

Applies to:

Oracle WebLogic Server - Version to [Release 12c]
Information in this document applies to any platform.


Using the Servlet 3.0 feature of creating a javax.servlet.ServletContainerInitializer,the javax.servlet.annotation.HandlesTypes annotation allows you to indicate which classes on the classpath to pass into the public void onStartup(final Set<Class> c, final ServletContext ctx) method. If we specify @HandlesType(MyHandledInterface.class),any class that directly implements MyHandledInterface will be provided to onStartup(c, ctx).

However,if we introduce an abstract class named AbstractHandledClass (for example) that implements MyInterface, and then create another class named MyHandledClass that extends AbstractHandledClass, MyHandledClass will not be provided in the set of classes given to onStartup(c, ctx). The set of classes (named c) will contain AbstractMyHandledClass, but it will not contain MyHandledClass.

Ideally we would expect MyHandledClass to be included in the set of classes because it does, in fact, implement MyInterface. It just does not implement it directly.But we notice on WLS 12.1.2 that MyHandledClass is not being provided in the set of classes given to onStartup(c, ctx).


To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!

In this Document

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.