You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2012/01/27 18:59:45 UTC

DO NOT REPLY [Bug 52545] New: Annotations are processed for servlet 2.4 applications

https://issues.apache.org/bugzilla/show_bug.cgi?id=52545

             Bug #: 52545
           Summary: Annotations are processed for servlet 2.4 applications
           Product: Tomcat 7
           Version: 7.0.23
          Platform: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Servlet & JSP API
        AssignedTo: dev@tomcat.apache.org
        ReportedBy: eugene.petrenko@jetbrains.com
    Classification: Unclassified


Under Tomcat 7.0.23 I have an application
with the following web.xml:


<?xml version="1.0" encoding="UTF-8"?>
<web-app id="BuildServer" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
  <display-name>Jetbrains TeamCity</display-name>

In debugger I see that metadata-complete parameter is set to 'false' meaning
that Tomcat processes all of my classes to contain annotations. There are no
annotated classes as I have a Servlet 2.4 API based application. I suppose
Tomcat must not process annotations for 2.4 applications at all (as there is
nothing for annotations processing in the spec)

Upgrading to 2.5 with explicit metadata-complete="true" attribute fixed the
issue.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 52545] Annotations are processed for servlet 2.4 applications

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52545

Eugene Petrenko <eu...@jetbrains.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |

--- Comment #2 from Eugene Petrenko <eu...@jetbrains.com> 2012-01-29 19:10:23 UTC ---
I saw the code. Default value of the flag to ignore attributes is false. As
parse code is never called, the value is false at the end (i.e. setter code was
not called). 

What I did was to check with debugger that the option to scan annotation was
not disabled for 2.4 application.

To workaround the bug I had to upgrade to 2.5 and explicitly specify
metadata-complete attribute with value="true"

PS. Annotation scanning mechanism uses too much synchronizations and thus slows
down the application.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 52545] Annotations are processed for servlet 2.4 applications

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52545

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |INVALID

--- Comment #5 from Mark Thomas <ma...@apache.org> 2012-03-08 15:36:08 UTC ---
The test application is not a valid Servlet 2.4 application.

The issues are:
- The application has been compiled against a later version of the Servlet API.
It is therefore possible that it may call methods that are not valid in Servlet
2.4. Tomcat makes no efforts to ensure that applications claiming a particular
version of the specification do not use API calls from a later version of the
specification unless the specification explicitly requires it to provide
special handling (e.g. for backwards compatibility). To provide general
protection of this nature would add complexity and impact performance to
address what is essentially a build issue.

- The application can not be compiled using a 1.4 JDK (the minimum Java version
required by Servlet 2.4) since it uses annotations. While applications may be
compiled with a later Java version, they must be compilable with the minimum
Java version.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 52545] Annotations are processed for servlet 2.4 applications

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52545

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID
         OS/Version|                            |All

--- Comment #1 from Mark Thomas <ma...@apache.org> 2012-01-28 19:53:58 UTC ---
The following test surrounds the annotation scanning:
if (webXml.getMajorVersion() >= 3) {
...
}
and a 2.4 web-app (the JSP examples from Tomcat 5.5) reports a major version o2
so no scanning will take place.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 52545] Annotations are processed for servlet 2.4 applications

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52545

--- Comment #4 from David Wahler <dw...@indeed.com> 2012-03-08 01:45:00 UTC ---
Created attachment 28438
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=28438
test case

Attached a trivial test case that works on Tomcat 5.5.20 but fails to start on
7.0.25. The application refers to servlet API 2.4, and contains a listener
whose single field is annotated with @javax.annotation.Resource. The logs
contain this error:

Mar 7, 2012 7:27:32 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Error configuring application listener of class testcase.Listener
javax.naming.NameNotFoundException: Name testcase.Listener is not bound in this
Context
        at org.apache.naming.NamingContext.lookup(NamingContext.java:820)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
        at
org.apache.catalina.core.DefaultInstanceManager.lookupFieldResource(DefaultInstanceManager.java:578)
        at
org.apache.catalina.core.DefaultInstanceManager.processAnnotations(DefaultInstanceManager.java:468)
        at
org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:144)
        at
org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:125)
        at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4715)
        at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at
org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1362)
        at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1450)
        at
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:295)
        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.ContainerBase.backgroundProcess(ContainerBase.java:1381)
        at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1539)
        at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1549)
        at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1528)
        at java.lang.Thread.run(Thread.java:662)
Mar 7, 2012 7:27:32 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Skipped installing application listeners due to previous error(s)

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 52545] Annotations are processed for servlet 2.4 applications

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52545

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |INVALID

--- Comment #3 from Mark Thomas <ma...@apache.org> 2012-01-29 19:12:28 UTC ---
I tested this with a 2.4 app and no scanning was performed. If you can provide
a webapp that triggers scanning on a clean 7.0.25 installation feel free to
rte-open this.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 52545] Annotations are processed for servlet 2.4 applications

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52545

David Wahler <dw...@indeed.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dwahler@indeed.com

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 52545] Annotations are processed for servlet 2.4 applications

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52545

David Wahler <dw...@indeed.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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