Index: java/org/apache/catalina/core/DefaultInstanceManager.java =================================================================== --- java/org/apache/catalina/core/DefaultInstanceManager.java (revision 1434910) +++ java/org/apache/catalina/core/DefaultInstanceManager.java (working copy) @@ -349,9 +349,9 @@ annotations.add(new AnnotationCacheEntry( method.getName(), method.getParameterTypes(), - injections.get(method.getName()), + injections.get(fieldName), AnnotationCacheEntryType.SETTER)); - break; + continue; } } if (method.isAnnotationPresent(Resource.class)) { Index: test/org/apache/catalina/startup/TestContextConfig.java =================================================================== --- test/org/apache/catalina/startup/TestContextConfig.java (revision 1435107) +++ test/org/apache/catalina/startup/TestContextConfig.java (working copy) @@ -126,6 +126,26 @@ assertPageContains("/test/testServlet", "postConstruct1()"); } + @Test + public void testBug54448() throws Exception { + Tomcat tomcat = getTomcatInstance(); + + File appDir = new File("test/webapp-3.0-fragments"); + Context context = tomcat.addWebapp(null, "/test", + appDir.getAbsolutePath()); + + Tomcat.addServlet(context, "TestServlet", + "org.apache.catalina.startup.TesterServletWithAnnotations"); + context.addServletMapping("/testServlet", "TestServlet"); + + tomcat.enableNaming(); + + tomcat.start(); + + assertPageContains("/test/testServlet", + "envEntry: 1 envEntry1: 2 envEntry2: 33 envEntry3: 4"); + } + private static class CustomDefaultServletSCI implements ServletContainerInitializer { Index: test/webapp-3.0-fragments/WEB-INF/web.xml =================================================================== --- test/webapp-3.0-fragments/WEB-INF/web.xml (revision 1434910) +++ test/webapp-3.0-fragments/WEB-INF/web.xml (working copy) @@ -57,4 +57,23 @@ org.apache.catalina.startup.TesterServletWithLifeCycleMethods preDestroy1 + + + envEntry1 + java.lang.Integer + 2 + + org.apache.catalina.startup.TesterServletWithAnnotations + envEntry1 + + + + envEntry2 + java.lang.Integer + 33 + + org.apache.catalina.startup.TesterServletWithAnnotations + envEntry2 + + \ No newline at end of file Index: test/org/apache/catalina/startup/TesterServletWithAnnotations.java =================================================================== --- test/org/apache/catalina/startup/TesterServletWithAnnotations.java (revision 0) +++ test/org/apache/catalina/startup/TesterServletWithAnnotations.java (working copy) @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.catalina.startup; + +import java.io.IOException; + +import javax.annotation.Resource; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class TesterServletWithAnnotations extends HttpServlet { + + private static final long serialVersionUID = 1L; + + @Resource(mappedName = "1") + private int envEntry; + + private int envEntry1; + + private int envEntry2; + + private int envEntry3; + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + resp.setContentType("text/plain"); + resp.getWriter().print("envEntry: " + envEntry); + resp.getWriter().print(" envEntry1: " + envEntry1); + resp.getWriter().print(" envEntry2: " + envEntry2); + resp.getWriter().print(" envEntry3: " + envEntry3); + } + + public void setEnvEntry1(int envEntry1) { + this.envEntry1 = envEntry1; + } + + @Resource(mappedName = "3") + public void setEnvEntry2(int envEntry2) { + this.envEntry2 = envEntry2; + } + + @Resource(mappedName = "4") + public void setEnvEntry3(int envEntry3) { + this.envEntry3 = envEntry3; + } + +} Property changes on: test/org/apache/catalina/startup/TesterServletWithAnnotations.java ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property