Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
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 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
—
Steps to reproduce:
1. Edit <TOMEE_HOME>/conf/context.xml and add jndiExceptionOnFailedWrite='false' attribute to the context element.
<Context jndiExceptionOnFailedWrite='false'>
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
</Context>
2. Execute this simple servlet:
@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); } }
WebApp is attached for convenience
Attachments
Attachments
Issue Links
- links to