Bug 54450 - Injection fails when part of the servlet properties uses @Resource and the other uses 'injection-target'
Summary: Injection fails when part of the servlet properties uses @Resource and the ot...
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 7.0.35
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-18 18:18 UTC by Violeta Georgieva
Modified: 2013-01-23 11:03 UTC (History)
0 users



Attachments
patch proposal + test (6.01 KB, patch)
2013-01-18 18:20 UTC, Violeta Georgieva
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Violeta Georgieva 2013-01-18 18:18:08 UTC
Hi,

I have a servlet with:
- annotated properties
- and injection-target declarations in web.xml

When I try to request this servlet I receive:


javax.naming.NameNotFoundException: Name [envEntry1] is not bound in this Context. Unable to find [envEntry1].
	at org.apache.naming.NamingContext.lookup(NamingContext.java:820)
	at org.apache.naming.NamingContext.lookup(NamingContext.java:154)
	at org.apache.naming.NamingContext.lookup(NamingContext.java:831)
	at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
	at org.apache.catalina.core.DefaultInstanceManager.lookupMethodResource(DefaultInstanceManager.java:622)
	at org.apache.catalina.core.DefaultInstanceManager.processAnnotations(DefaultInstanceManager.java:466)
	at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:157)
	at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:138)
	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1137)
	at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:858)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:136)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:680)


The problem is that when the application uses 'injection-target' declarations in 

org.apache.catalina.core.DefaultInstanceManager.populateAnnotationsCache(Class<?>, Map<String, String>)

only the first setter method is evaluated and the rest are skipped.


I would like to propose a patch and test case.

I'm looking forward to your comments.

Regards
Violeta
Comment 1 Violeta Georgieva 2013-01-18 18:20:26 UTC
Created attachment 29867 [details]
patch proposal + test

The test case extends the test case from https://issues.apache.org/bugzilla/show_bug.cgi?id=54448
Comment 2 Mark Thomas 2013-01-23 11:03:16 UTC
Thanks once again for the report, test case and patch. The patch has been applied to trunk and 7.0.x and will be included in 7.0.36 onwards.