You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by "Shrivastava, Vijay" <vs...@informatica.com.INVALID> on 2021/04/12 10:51:19 UTC

Annotations aren't working with tomcat 9

Hi,

@webservlet & @webListner annotations aren't working.

Classes in which we are using these annotations are present in jar which is getting scanned but registration of servlet with tomcat is not happening.

What we have tried to fix:

  1.  To confirm the issue we downgraded Tomcat version in Mercury 10.5 from Tomcat 9 to Tomcat 7. With Tomcat 7,  servlets get registered with Tomcat and hence annotation scanning is happening as desired.
  2.  Tried setting properties values mentioned in the $INFA_HOME/tomcat/conf/catalina.properties file related to "jarSkip", but no luck.
  3.  Tried adding "metadata-complete" tag to false/true in web.xml as per Servlet 4.0 specification, but no luck.


Things that worked-
1 - We put these classes at web-inf\classes folder,
2 - Added entry for the servlet in we.xml file.

Since in our case these servlets are dynamically added via installer. We can't use any of the above method.

Can anyone please help us with this?

We are using below configuration:
Tomcat version details:
Server built:   Dec 3 2020 11:43:00 UTC
Server number:  9.0.41.0
OS Name:        Linux
OS Version:     3.10.0-693.el7.x86_64
Architecture:   amd64
JVM Version:    1.8.0_191-b12
JVM Vendor:     Oracle Corporation

annotation-api.jar - version - 1.3
Servlet-api.jar -  version -4.0

Thanks & Regards,
Vijay Shrivastava

Re: Annotations aren't working with tomcat 9

Posted by Rémy Maucherat <re...@apache.org>.
On Mon, Apr 12, 2021 at 12:51 PM Shrivastava, Vijay
<vs...@informatica.com.invalid> wrote:

> Hi,
>
> @webservlet & @webListner annotations aren't working.
>
> Classes in which we are using these annotations are present in jar which
> is getting scanned but registration of servlet with tomcat is not happening.
>
> What we have tried to fix:
>
>   1.  To confirm the issue we downgraded Tomcat version in Mercury 10.5
> from Tomcat 9 to Tomcat 7. With Tomcat 7,  servlets get registered with
> Tomcat and hence annotation scanning is happening as desired.
>   2.  Tried setting properties values mentioned in the
> $INFA_HOME/tomcat/conf/catalina.properties file related to "jarSkip", but
> no luck.
>   3.  Tried adding "metadata-complete" tag to false/true in web.xml as per
> Servlet 4.0 specification, but no luck.
>
>
> Things that worked-
> 1 - We put these classes at web-inf\classes folder,
> 2 - Added entry for the servlet in we.xml file.
>
> Since in our case these servlets are dynamically added via installer. We
> can't use any of the above method.
>
> Can anyone please help us with this?
>

We probably could help if you had posted in the Tomcat user mailing list
instead.
http://tomcat.apache.org/lists.html#tomcat-users

Rémy


>
> We are using below configuration:
> Tomcat version details:
> Server built:   Dec 3 2020 11:43:00 UTC
> Server number:  9.0.41.0
> OS Name:        Linux
> OS Version:     3.10.0-693.el7.x86_64
> Architecture:   amd64
> JVM Version:    1.8.0_191-b12
> JVM Vendor:     Oracle Corporation
>
> annotation-api.jar - version - 1.3
> Servlet-api.jar -  version -4.0
>
> Thanks & Regards,
> Vijay Shrivastava
>