You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by "Svetlin Zarev (JIRA)" <ji...@apache.org> on 2017/06/22 12:03:00 UTC

[jira] [Updated] (TOMEE-2074) TomcatWebAppBuilder does not correctly set NamingContextListener.setExceptionOnFailedWrite()

     [ https://issues.apache.org/jira/browse/TOMEE-2074?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Svetlin Zarev updated TOMEE-2074:
---------------------------------
    Description: 
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 write-ability of 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

  was:
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 write-ability of 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


>  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 write-ability of 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)