You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/06/22 14:07:00 UTC
[jira] [Commented] (TOMEE-2074) TomcatWebAppBuilder does not
correctly set NamingContextListener.setExceptionOnFailedWrite()
[ https://issues.apache.org/jira/browse/TOMEE-2074?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16059444#comment-16059444 ]
ASF GitHub Bot commented on TOMEE-2074:
---------------------------------------
GitHub user SvetlinZarev opened a pull request:
https://github.com/apache/tomee/pull/77
TOMEE-2074: TomcatWebAppBuilder does not correctly set NamingContextListener.setExceptionOnFailedWrite()
OpenEjbContextConfig should reconfigure the NamingContextListener after it process the context.xml
----
Execution flow:
1. TomcatWebAppBuilder:890 creates new NamingContextLisener
2. TomcatWebAppBuilder sets the "exceptionOnFailedWrite" property on the NamingContextLisener to the value retrieved from the standard context - at this point in time it's the default value, because the context.xml has not been processed yet.
3. The context.xml is processed -> OpenEJBContextConfig::contextConfig()
4. The Digester sets that property on the StandardContext instance
5. The NamingContextListener configures the naming context
namingContext.setExceptionOnFailedWrite(getExceptionOnFailedWrite());
Where getExceptionOnFailedWrite() returns the value we set in step 2 (i.e. it returns the default value).
6. As a result the naming context is not configured with the user-provided configuration in context.xml
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/SvetlinZarev/tomee tomee-2074
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/tomee/pull/77.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #77
----
commit 9e2de13f3548a5ff31a9bd672a620a2fa1ab2e10
Author: Svetlin Zarev <sv...@sap.com>
Date: 2017-06-22T13:23:03Z
TOMEE-2074: Implement test which verifies that TomcatWebAppBuilder properly processes the jndiExceptionOnFailedWrite context attribute
commit d38874d9a5a5e77a5e364bb909851ca07340d131
Author: Svetlin Zarev <sv...@sap.com>
Date: 2017-06-22T14:03:01Z
Fix TOMEE-2074
OpenEjbContextConfig should reconfigure the NamingContextListener
---
1. TomcatWebAppBuilder:890 creates new NamingContextLisener
2. TomcatWebAppBuilder sets the "exceptionOnFailedWrite" property on the NamingContextLisener to the value retrieved from the standard context - at this point in time it's the default value, because the context.xml has not been processed yet.
3. The context.xml is processed -> OpenEJBContextConfig::contextConfig()
4. The Digester sets that property on the StandardContext instance
5. The NamingContextListener configures the naming context
namingContext.setExceptionOnFailedWrite(getExceptionOnFailedWrite());
Where getExceptionOnFailedWrite() returns the value we set in step 2 (i.e. it returns the default value).
6. As a result the naming context is not configured with the user-provided configuration in context.xml
----
> TomcatWebAppBuilder does not correctly set NamingContextListener.setExceptionOnFailedWrite()
> ----------------------------------------------------------------------------------------------
>
> Key: TOMEE-2074
> URL: https://issues.apache.org/jira/browse/TOMEE-2074
> Project: TomEE
> Issue Type: Bug
> Reporter: Svetlin Zarev
> Attachments: sample.zip
>
>
> The TomcatWebAppBuilder does not correctly set the NamingContextListener.setExceptionOnFailedWrite() property - it always sets the default value which is "true", instead of the one specified in the context.xml
> ---
> *Execution flow:*
> 1. TomcatWebAppBuilder:890 creates new NamingContextLisener
> 2. TomcatWebAppBuilder sets the "exceptionOnFailedWrite" property on the NamingContextLisener to the value retrieved from the standard context - at this point in time it's the default value, because the context.xml has not been processed yet.
> 3. The context.xml is processed -> OpenEJBContextConfig::contextConfig()
> 4. The Digester sets that property on the StandardContext instance
> 5. The NamingContextListener configures the naming context
> {code}
> namingContext.setExceptionOnFailedWrite(getExceptionOnFailedWrite());
> {code}
> Where getExceptionOnFailedWrite() returns the value we set in step 2 (i.e. it returns the default value).
> 6. As a result the naming context is not configured with the user-provided configuration in context.xml
> ---
> *Steps to reproduce:*
> 1. Edit <TOMEE_HOME>/conf/context.xml and add jndiExceptionOnFailedWrite='false' attribute to the context element.
> {code}
> <Context jndiExceptionOnFailedWrite='false'>
> <WatchedResource>WEB-INF/web.xml</WatchedResource>
> <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
> </Context>
> {code}
> 2. Execute this simple servlet:
> {code}
> @Override
> protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
> resp.setContentType("text/plain");
> final PrintWriter writer = resp.getWriter();
> try {
> final InitialContext ctx = new InitialContext();
> final Context compEnv = (Context) ctx.lookup("java:comp/env");
> compEnv.close();
> writer.println("Closed");
> } catch (Exception ex) {
> writer.println("Failed to close context: ");
> ex.printStackTrace(writer);
> }
> }
> {code}
> WebApp is attached for convenience
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)