сб, 2 апр. 2022 г. в 00:02, Cherio <che...@gmail.com>:
>
> I observed an announced change in behavior in version 9.0.60 (and later).
>
> My application has a Spring class loaded as a javax.servlet.Filter. It has
> a method annotated with a PostConstruct annotation. Up until Tomcat 9.0.59
> the annotation was handled by Spring. Starting with Tomcat 9.0.60 behavior
> changed. Now Tomcat attempts to take action on that method. The attempt
> fails with "java.lang.IllegalArgumentException: Invalid
> javax.annotation.PostConstruct annotation" exception and that results in
> the whole application failing to start.

1. You have to provide a stacktrace for that error.
Without a stacktrace the above are just words.
The stack trace will show whether it is Tomcat code that is failing,
or there is Spring code in the call chain.
Also (if version of Tomcat is known as well), one can match it to
source code and see at what step in the startup sequence it happened.

2. You say that it is a javax.servlet.Filter and it is coded so that
Tomcat will not be able to create an instance of that class - proper
creation of an instance of that filter must be done by Spring, so that
Spring processes those PostConstruct annotations.

Am I understanding you correctly?

If so, then that Filter is not part of the web application itself
(cannot be declared in web.xml, cannot be annotated with
javax.servlet.annotation.WebFilter annotation). It should be
instantiated by Spring and injected into the starting web application.
Right?

3. Annotation scanning is configurable to some extent.
It is possible to turn off some scanning, or configure it to scan/do
not scan some jars.

See the following wiki page for links:
https://cwiki.apache.org/confluence/display/TOMCAT/HowTo+FasterStartUp#HowToFasterStartUp-JARscanning


> I use PostConstruct in other Spring modules but it looks like Tomcat cares
> only about classes it deals with directly.
>
> I do not see this change documented anywhere so I assume this may be a
> regression or an undocumented bug fix or feature.
>
> Does anyone have more information about this?
> Thanks!

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to