You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2018/05/10 12:46:44 UTC
svn commit: r1831333 - in /tomcat/trunk: java/org/apache/catalina/core/
java/org/apache/catalina/deploy/ test/org/apache/naming/
test/webapp-fragments/ test/webapp-fragments/WEB-INF/ webapps/docs/
Author: markt
Date: Thu May 10 12:46:44 2018
New Revision: 1831333
URL: http://svn.apache.org/viewvc?rev=1831333&view=rev
Log:
Partial fix for BZ 50019
Add lookup-name support to env-entry
Added:
tomcat/trunk/test/org/apache/naming/TestEnvEntry.java (with props)
tomcat/trunk/test/org/apache/naming/TesterEnvEntry.java (with props)
tomcat/trunk/test/org/apache/naming/TesterInjectionServlet.java (with props)
tomcat/trunk/test/webapp-fragments/jndi.jsp (with props)
Modified:
tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties
tomcat/trunk/java/org/apache/catalina/core/NamingContextListener.java
tomcat/trunk/java/org/apache/catalina/deploy/LocalStrings.properties
tomcat/trunk/java/org/apache/catalina/deploy/NamingResourcesImpl.java
tomcat/trunk/test/webapp-fragments/WEB-INF/web.xml
tomcat/trunk/webapps/docs/changelog.xml
Modified: tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties?rev=1831333&r1=1831332&r2=1831333&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties Thu May 10 12:46:44 2018
@@ -105,6 +105,9 @@ jreLeakListener.xmlParseFail=Error whils
jreLeakListener.authPolicyFail=Error whilst attempting to prevent memory leak in javax.security.auth.Policy class
jreLeakListener.ldapPoolManagerFail=Failed to trigger creation of the com.sun.jndi.ldap.LdapPoolManager class during Tomcat start to prevent possible memory leaks. This is expected on non-Sun JVMs.
jreLeakListener.classToInitializeFail=Failed to load class [{0}] during Tomcat start to prevent possible memory leaks.
+
+naming.addEnvEntry=Adding environment entry [{0}]
+naming.addResourceEnvRef=Adding resource env ref [{0}]
naming.wsdlFailed=Failed to find wsdl file: [{0}]
naming.bindFailed=Failed to bind object: [{0}]
naming.jmxRegistrationFailed=Failed to register in JMX: [{0}]
Modified: tomcat/trunk/java/org/apache/catalina/core/NamingContextListener.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/NamingContextListener.java?rev=1831333&r1=1831332&r2=1831333&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/NamingContextListener.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/NamingContextListener.java Thu May 10 12:46:44 2018
@@ -53,6 +53,7 @@ import org.apache.naming.ContextAccessCo
import org.apache.naming.ContextBindings;
import org.apache.naming.EjbRef;
import org.apache.naming.HandlerRef;
+import org.apache.naming.LookupRef;
import org.apache.naming.NamingContext;
import org.apache.naming.ResourceEnvRef;
import org.apache.naming.ResourceLinkRef;
@@ -69,6 +70,7 @@ import org.apache.tomcat.util.descriptor
import org.apache.tomcat.util.descriptor.web.ContextResourceLink;
import org.apache.tomcat.util.descriptor.web.ContextService;
import org.apache.tomcat.util.descriptor.web.ContextTransaction;
+import org.apache.tomcat.util.descriptor.web.ResourceBase;
import org.apache.tomcat.util.modeler.Registry;
import org.apache.tomcat.util.res.StringManager;
@@ -680,86 +682,89 @@ public class NamingContextListener
*/
public void addEnvironment(ContextEnvironment env) {
- Object value = null;
- // Instantiating a new instance of the correct object type, and
- // initializing it.
- String type = env.getType();
- try {
- if (type.equals("java.lang.String")) {
- value = env.getValue();
- } else if (type.equals("java.lang.Byte")) {
- if (env.getValue() == null) {
- value = Byte.valueOf((byte) 0);
- } else {
- value = Byte.decode(env.getValue());
- }
- } else if (type.equals("java.lang.Short")) {
- if (env.getValue() == null) {
- value = Short.valueOf((short) 0);
- } else {
- value = Short.decode(env.getValue());
- }
- } else if (type.equals("java.lang.Integer")) {
- if (env.getValue() == null) {
- value = Integer.valueOf(0);
- } else {
- value = Integer.decode(env.getValue());
- }
- } else if (type.equals("java.lang.Long")) {
- if (env.getValue() == null) {
- value = Long.valueOf(0);
- } else {
- value = Long.decode(env.getValue());
- }
- } else if (type.equals("java.lang.Boolean")) {
- value = Boolean.valueOf(env.getValue());
- } else if (type.equals("java.lang.Double")) {
- if (env.getValue() == null) {
- value = Double.valueOf(0);
- } else {
- value = Double.valueOf(env.getValue());
- }
- } else if (type.equals("java.lang.Float")) {
- if (env.getValue() == null) {
- value = Float.valueOf(0);
- } else {
- value = Float.valueOf(env.getValue());
- }
- } else if (type.equals("java.lang.Character")) {
- if (env.getValue() == null) {
- value = Character.valueOf((char) 0);
- } else {
- if (env.getValue().length() == 1) {
- value = Character.valueOf(env.getValue().charAt(0));
+ Object value = lookForLookupRef(env);
+
+ if (value == null) {
+ // Instantiating a new instance of the correct object type, and
+ // initializing it.
+ String type = env.getType();
+ try {
+ if (type.equals("java.lang.String")) {
+ value = env.getValue();
+ } else if (type.equals("java.lang.Byte")) {
+ if (env.getValue() == null) {
+ value = Byte.valueOf((byte) 0);
} else {
- throw new IllegalArgumentException();
+ value = Byte.decode(env.getValue());
+ }
+ } else if (type.equals("java.lang.Short")) {
+ if (env.getValue() == null) {
+ value = Short.valueOf((short) 0);
+ } else {
+ value = Short.decode(env.getValue());
+ }
+ } else if (type.equals("java.lang.Integer")) {
+ if (env.getValue() == null) {
+ value = Integer.valueOf(0);
+ } else {
+ value = Integer.decode(env.getValue());
+ }
+ } else if (type.equals("java.lang.Long")) {
+ if (env.getValue() == null) {
+ value = Long.valueOf(0);
+ } else {
+ value = Long.decode(env.getValue());
+ }
+ } else if (type.equals("java.lang.Boolean")) {
+ value = Boolean.valueOf(env.getValue());
+ } else if (type.equals("java.lang.Double")) {
+ if (env.getValue() == null) {
+ value = Double.valueOf(0);
+ } else {
+ value = Double.valueOf(env.getValue());
+ }
+ } else if (type.equals("java.lang.Float")) {
+ if (env.getValue() == null) {
+ value = Float.valueOf(0);
+ } else {
+ value = Float.valueOf(env.getValue());
+ }
+ } else if (type.equals("java.lang.Character")) {
+ if (env.getValue() == null) {
+ value = Character.valueOf((char) 0);
+ } else {
+ if (env.getValue().length() == 1) {
+ value = Character.valueOf(env.getValue().charAt(0));
+ } else {
+ throw new IllegalArgumentException();
+ }
+ }
+ } else {
+ value = constructEnvEntry(env.getType(), env.getValue());
+ if (value == null) {
+ log.error(sm.getString(
+ "naming.invalidEnvEntryType", env.getName()));
}
}
- } else {
- value = constructEnvEntry(env.getType(), env.getValue());
- if (value == null) {
- log.error(sm.getString(
- "naming.invalidEnvEntryType", env.getName()));
- }
+ } catch (NumberFormatException e) {
+ log.error(sm.getString("naming.invalidEnvEntryValue", env.getName()));
+ } catch (IllegalArgumentException e) {
+ log.error(sm.getString("naming.invalidEnvEntryValue", env.getName()));
}
- } catch (NumberFormatException e) {
- log.error(sm.getString("naming.invalidEnvEntryValue", env.getName()));
- } catch (IllegalArgumentException e) {
- log.error(sm.getString("naming.invalidEnvEntryValue", env.getName()));
}
// Binding the object to the appropriate name
if (value != null) {
try {
- if (log.isDebugEnabled())
- log.debug(" Adding environment entry " + env.getName());
+ if (log.isDebugEnabled()) {
+ log.debug(sm.getString("naming.addEnvEntry", env.getName()));
+ }
createSubcontexts(envCtx, env.getName());
envCtx.bind(env.getName(), value);
} catch (NamingException e) {
log.error(sm.getString("naming.invalidEnvEntryValue", e));
}
}
-
}
@@ -996,15 +1001,16 @@ public class NamingContextListener
StringRefAddr refAddr = new StringRefAddr(paramName, paramValue);
ref.add(refAddr);
}
+
try {
- if (log.isDebugEnabled())
- log.debug(" Adding resource env ref " + resourceEnvRef.getName());
+ if (log.isDebugEnabled()) {
+ log.debug(sm.getString("naming.addResourceEnvRef", resourceEnvRef.getName()));
+ }
createSubcontexts(envCtx, resourceEnvRef.getName());
envCtx.bind(resourceEnvRef.getName(), ref);
} catch (NamingException e) {
log.error(sm.getString("naming.bindFailed", e));
}
-
}
@@ -1194,4 +1200,17 @@ public class NamingContextListener
}
+ /**
+ * Gets look up reference from resource if exist.
+ *
+ * @param resourceBase resource base object
+ * @return lookup ref
+ */
+ private LookupRef lookForLookupRef(ResourceBase resourceBase) {
+ String lookupName = resourceBase.getLookupName();
+ if ((lookupName != null && !lookupName.equals(""))) {
+ return new LookupRef(resourceBase.getType(), lookupName);
+ }
+ return null;
+ }
}
Modified: tomcat/trunk/java/org/apache/catalina/deploy/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/deploy/LocalStrings.properties?rev=1831333&r1=1831332&r2=1831333&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/deploy/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/catalina/deploy/LocalStrings.properties Thu May 10 12:46:44 2018
@@ -18,6 +18,7 @@ namingResources.cleanupCloseSecurity=Una
namingResources.cleanupNoClose=Resource [{0}] in container [{1}] does not have a [{2}] method so no cleanup was performed for that resource
namingResources.cleanupNoContext=Failed to retrieve JNDI naming context for container [{0}] so no cleanup was performed for that container
namingResources.cleanupNoResource=Failed to retrieve JNDI resource [{0}] for container [{1}] so no cleanup was performed for that resource
+namingResources.envEntryLookupValue=The environment entry [{0}] specifies both a lookup-name and a value
namingResources.mbeanCreateFail=Failed to create MBean for naming resource [{0}]
namingResources.mbeanDestroyFail=Failed to destroy MBean for naming resource [{0}]
namingResources.resourceTypeFail=The JNDI resource named [{0}] is of type [{1}] but the type is inconsistent with the type(s) of the injection target(s) configured for that resource
Modified: tomcat/trunk/java/org/apache/catalina/deploy/NamingResourcesImpl.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/deploy/NamingResourcesImpl.java?rev=1831333&r1=1831332&r2=1831333&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/deploy/NamingResourcesImpl.java (original)
+++ tomcat/trunk/java/org/apache/catalina/deploy/NamingResourcesImpl.java Thu May 10 12:46:44 2018
@@ -24,6 +24,7 @@ import java.lang.reflect.InvocationTarge
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -262,12 +263,22 @@ public class NamingResourcesImpl extends
}
}
+ List<InjectionTarget> injectionTargets = environment.getInjectionTargets();
+ String value = environment.getValue();
+ String lookupName = environment.getLookupName();
+
// Entries with injection targets but no value are effectively ignored
- if (environment.getInjectionTargets() != null && environment.getInjectionTargets().size() > 0 &&
- (environment.getValue() == null || environment.getValue().length() == 0)) {
+ if (injectionTargets != null && injectionTargets.size() > 0 &&
+ (value == null || value.length() == 0)) {
return;
}
+ // Entries with lookup-name and value are an error (EE.5.4.1.3)
+ if (value != null && value.length() > 0 && lookupName != null && lookupName.length() > 0) {
+ throw new IllegalArgumentException(
+ sm.getString("namingResources.envEntryLookupValue", environment.getName()));
+ }
+
if (!checkResourceType(environment)) {
throw new IllegalArgumentException(sm.getString(
"namingResources.resourceTypeFail", environment.getName(),
Added: tomcat/trunk/test/org/apache/naming/TestEnvEntry.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/naming/TestEnvEntry.java?rev=1831333&view=auto
==============================================================================
--- tomcat/trunk/test/org/apache/naming/TestEnvEntry.java (added)
+++ tomcat/trunk/test/org/apache/naming/TestEnvEntry.java Thu May 10 12:46:44 2018
@@ -0,0 +1,136 @@
+/*
+ * 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.naming;
+
+import java.io.File;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.startup.Tomcat;
+import org.apache.catalina.startup.TomcatBaseTest;
+import org.apache.tomcat.util.buf.ByteChunk;
+
+public class TestEnvEntry extends TomcatBaseTest {
+
+ @Test
+ public void testEnvEntryBasic() throws Exception {
+ doTestJndiLookup("env-entry/basic", "basic-value");
+ }
+
+
+ @Test
+ public void testEnvEntryValid() throws Exception {
+ doTestJndiLookup("env-entry/valid", "valid");
+ }
+
+
+ @Test
+ public void testEnvEntryInvalid() throws Exception {
+ doTestJndiLookup("env-entry/invalid", "Not Found");
+ }
+
+
+ @Test
+ public void testEnvEntryInjectField() throws Exception {
+ doTestJndiInjection("property1", "inject-value-1");
+ }
+
+
+ @Test
+ public void testEnvEntryInjectProperty() throws Exception {
+ doTestJndiInjection("property2", "inject-value-2");
+ }
+
+
+ @Test
+ public void testEnvEntryInjectFieldNoType() throws Exception {
+ doTestJndiInjection("property3", "inject-value-3");
+ }
+
+
+ @Test
+ public void testEnvEntryInjectionNoValue() throws Exception {
+ doTestJndiLookup("env-entry/injectNoValue", "Not Found");
+ }
+
+
+ @Test
+ public void testEnvEntryLookup() throws Exception {
+ doTestJndiLookup("env-entry/lookup", "basic-value");
+ }
+
+
+ @Test
+ public void testEnvEntryLookupCircular() throws Exception {
+ doTestJndiLookup("env-entry/circular1", "Naming Error");
+ }
+
+
+ @Test
+ public void testEnvEntryLookupInvalid() throws Exception {
+ doTestJndiLookup("env-entry/lookup-invalid", "Naming Error");
+ }
+
+
+ private void doTestJndiLookup(String jndiName, String expected) throws Exception {
+ Tomcat tomcat = getTomcatInstance();
+
+ File appDir = new File("test/webapp-fragments");
+ tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());
+
+ tomcat.enableNaming();
+ tomcat.start();
+
+ ByteChunk out = new ByteChunk();
+
+ int rc = getUrl("http://localhost:" + getPort() + "/test/jndi.jsp?jndiName=" +
+ jndiName, out, null);
+ Assert.assertEquals(HttpServletResponse.SC_OK, rc);
+
+ // JSP has leading and trailing white-space
+ String result = out.toString().trim();
+ Assert.assertEquals(expected, result);
+ }
+
+
+ private void doTestJndiInjection(String injectionName, String expected) throws Exception {
+ Tomcat tomcat = getTomcatInstance();
+
+ File appDir = new File("test/webapp-fragments");
+ Context context = tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());
+
+ Tomcat.addServlet(context, "InjectionServlet", "org.apache.naming.TesterInjectionServlet");
+ context.addServletMappingDecoded("/injection", "InjectionServlet");
+
+ tomcat.enableNaming();
+ tomcat.start();
+
+ ByteChunk out = new ByteChunk();
+
+ int rc = getUrl("http://localhost:" + getPort() + "/test/injection?injectionName=" +
+ injectionName, out, null);
+ Assert.assertEquals(HttpServletResponse.SC_OK, rc);
+
+ // JSP has leading and trailing white-space
+ String result = out.toString().trim();
+ Assert.assertEquals(expected, result);
+ }
+}
Propchange: tomcat/trunk/test/org/apache/naming/TestEnvEntry.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: tomcat/trunk/test/org/apache/naming/TesterEnvEntry.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/naming/TesterEnvEntry.java?rev=1831333&view=auto
==============================================================================
--- tomcat/trunk/test/org/apache/naming/TesterEnvEntry.java (added)
+++ tomcat/trunk/test/org/apache/naming/TesterEnvEntry.java Thu May 10 12:46:44 2018
@@ -0,0 +1,33 @@
+/*
+ * 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.naming;
+
+public class TesterEnvEntry {
+
+ private static final String VALID = "valid";
+
+ public TesterEnvEntry(String value) {
+ if (!VALID.equals(value)) {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return VALID;
+ }
+}
Propchange: tomcat/trunk/test/org/apache/naming/TesterEnvEntry.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: tomcat/trunk/test/org/apache/naming/TesterInjectionServlet.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/naming/TesterInjectionServlet.java?rev=1831333&view=auto
==============================================================================
--- tomcat/trunk/test/org/apache/naming/TesterInjectionServlet.java (added)
+++ tomcat/trunk/test/org/apache/naming/TesterInjectionServlet.java Thu May 10 12:46:44 2018
@@ -0,0 +1,68 @@
+/*
+ * 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.naming;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.tomcat.util.IntrospectionUtils;
+
+public class TesterInjectionServlet extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ private String property1 = null;
+ public String getProperty1() { return property1; }
+
+ // Not used directly.
+ // Here to ensure properties are injected in preference to fields
+ private String property2 = null;
+ public void setProperty2a(String property2) { this.property2 = property2; }
+ public String getProperty2a() { return property2; }
+
+ private String property2a = null;
+ public void setProperty2(String property2) { this.property2a = property2; }
+ public String getProperty2() { return property2a; }
+
+ private String property3 = null;
+ public String getProperty3() { return property3; }
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+
+ resp.setContentType("text/plain");
+ resp.setCharacterEncoding("UTF-8");
+
+ String injectionName = req.getParameter("injectionName");
+
+ PrintWriter pw = resp.getWriter();
+ pw.print(IntrospectionUtils.getProperty(this, injectionName));
+
+ // The property should tyake precedence over the field and this should
+ // be null
+ if (getProperty2a() != null) {
+ pw.println();
+ pw.print(getProperty2a());
+ }
+ }
+}
Propchange: tomcat/trunk/test/org/apache/naming/TesterInjectionServlet.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: tomcat/trunk/test/webapp-fragments/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/webapp-fragments/WEB-INF/web.xml?rev=1831333&r1=1831332&r2=1831333&view=diff
==============================================================================
--- tomcat/trunk/test/webapp-fragments/WEB-INF/web.xml (original)
+++ tomcat/trunk/test/webapp-fragments/WEB-INF/web.xml Thu May 10 12:46:44 2018
@@ -86,4 +86,94 @@
<env-entry-type>java.lang.Integer</env-entry-type>
<env-entry-value>66</env-entry-value>
</env-entry>
+
+ <servlet>
+ <servlet-name>injection</servlet-name>
+ <servlet-class>org.apache.naming.TesterInjectionServlet</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>injection</servlet-name>
+ <url-pattern>/injection</url-pattern>
+ </servlet-mapping>
+
+ <env-entry>
+ <env-entry-name>env-entry/basic</env-entry-name>
+ <env-entry-type>java.lang.String</env-entry-type>
+ <env-entry-value>basic-value</env-entry-value>
+ </env-entry>
+
+ <env-entry>
+ <env-entry-name>env-entry/valid</env-entry-name>
+ <env-entry-type>org.apache.naming.TesterEnvEntry</env-entry-type>
+ <env-entry-value>valid</env-entry-value>
+ </env-entry>
+
+ <env-entry>
+ <env-entry-name>env-entry/invalid</env-entry-name>
+ <env-entry-type>org.apache.naming.TesterEnvEntry</env-entry-type>
+ <env-entry-value>invalid</env-entry-value>
+ </env-entry>
+
+ <env-entry>
+ <env-entry-name>env-entry/injectField</env-entry-name>
+ <env-entry-type>java.lang.String</env-entry-type>
+ <env-entry-value>inject-value-1</env-entry-value>
+ <injection-target>
+ <injection-target-class>org.apache.naming.TesterInjectionServlet</injection-target-class>
+ <injection-target-name>property1</injection-target-name>
+ </injection-target>
+ </env-entry>
+
+ <env-entry>
+ <env-entry-name>env-entry/injectProperty</env-entry-name>
+ <env-entry-type>java.lang.String</env-entry-type>
+ <env-entry-value>inject-value-2</env-entry-value>
+ <injection-target>
+ <injection-target-class>org.apache.naming.TesterInjectionServlet</injection-target-class>
+ <injection-target-name>property2</injection-target-name>
+ </injection-target>
+ </env-entry>
+
+ <env-entry>
+ <env-entry-name>env-entry/injectFieldNoType</env-entry-name>
+ <env-entry-value>inject-value-3</env-entry-value>
+ <injection-target>
+ <injection-target-class>org.apache.naming.TesterInjectionServlet</injection-target-class>
+ <injection-target-name>property3</injection-target-name>
+ </injection-target>
+ </env-entry>
+
+ <env-entry>
+ <env-entry-name>env-entry/injectNoValue</env-entry-name>
+ <env-entry-type>java.lang.String</env-entry-type>
+ <injection-target>
+ <injection-target-class>org.apache.naming.TesterInjectionServlet</injection-target-class>
+ <injection-target-name>property4</injection-target-name>
+ </injection-target>
+ </env-entry>
+
+ <env-entry>
+ <env-entry-name>env-entry/lookup</env-entry-name>
+ <env-entry-type>java.lang.String</env-entry-type>
+ <lookup-name>java:comp/env/env-entry/basic</lookup-name>
+ </env-entry>
+
+ <env-entry>
+ <env-entry-name>env-entry/circular1</env-entry-name>
+ <env-entry-type>java.lang.String</env-entry-type>
+ <lookup-name>java:comp/env/env-entry/circular2</lookup-name>
+ </env-entry>
+
+ <env-entry>
+ <env-entry-name>env-entry/circular2</env-entry-name>
+ <env-entry-type>java.lang.String</env-entry-type>
+ <lookup-name>java:comp/env/env-entry/circular1</lookup-name>
+ </env-entry>
+
+ <env-entry>
+ <env-entry-name>env-entry/lookup-invalid</env-entry-name>
+ <env-entry-type>java.lang.Integer</env-entry-type>
+ <lookup-name>java:comp/env/env-entry/basic</lookup-name>
+ </env-entry>
+
</web-app>
\ No newline at end of file
Added: tomcat/trunk/test/webapp-fragments/jndi.jsp
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/webapp-fragments/jndi.jsp?rev=1831333&view=auto
==============================================================================
--- tomcat/trunk/test/webapp-fragments/jndi.jsp (added)
+++ tomcat/trunk/test/webapp-fragments/jndi.jsp Thu May 10 12:46:44 2018
@@ -0,0 +1,31 @@
+<%--
+ 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.
+--%>
+<%@page contentType="text/plain" pageEncoding="UTF-8"%><%
+ String jndiName = request.getParameter("jndiName");
+
+ javax.naming.Context initCtx = new javax.naming.InitialContext();
+ javax.naming.Context envCtx = (javax.naming.Context) initCtx.lookup("java:comp/env");
+
+ try {
+ Object obj = envCtx.lookup(jndiName);
+ out.println(obj.toString());
+ } catch (javax.naming.NameNotFoundException e) {
+ out.println("Not Found");
+ } catch (javax.naming.NamingException e) {
+ out.println("Naming Error");
+ }
+%>
\ No newline at end of file
Propchange: tomcat/trunk/test/webapp-fragments/jndi.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1831333&r1=1831332&r2=1831333&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Thu May 10 12:46:44 2018
@@ -77,6 +77,10 @@
<code>@Resource</code> annotations specify a name with an explicit
<code>java:</code> namespace. (markt)
</fix>
+ <fix>
+ Partial fix for <bug>50019</bug>: Add support for
+ <code><lookup-name></code> with environment entries. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org