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 2026/07/23 18:46:00 UTC
[jira] [Work logged] (TOMEE-4654) java:comp naming context accepts writes the Enterprise Beans spec requires it to refuse
[ https://issues.apache.org/jira/browse/TOMEE-4654?focusedWorklogId=1031915&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1031915 ]
ASF GitHub Bot logged work on TOMEE-4654:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 23/Jul/26 18:45
Start Date: 23/Jul/26 18:45
Worklog Time Spent: 10m
Work Description: jungm opened a new pull request, #2846:
URL: https://github.com/apache/tomee/pull/2846
## What
Makes the `java:comp` component naming context read-only by default, as the Enterprise Beans spec (10.4.4) and EE.5.3.4 require: write attempts against a deployed application's ENC must not take effect.
## Why
The `IvmContext` read-only enforcement already existed and was correct — `checkReadOnly()` throws `OperationNotSupportedException` and `setReadOnly()` cascades through the whole name tree. But nothing ever turned it on: `openejb.forceReadOnlyAppNamingContext` defaulted to `false`, so every deployed application got a fully writable `java:comp`, letting `bind`/`rebind`/`rename` through where the spec requires them refused.
## Changes
- **`Assembler`**: default `openejb.forceReadOnlyAppNamingContext` to `true` (kept as an explicit opt-out for anyone depending on the old writable behaviour).
- **`Assembler.setAppNamingContextReadOnly`**: also mark the `WebContext` and `AppContext` naming contexts read-only. Servlets and JSF managed beans resolve `java:comp`/`java:module`/`java:app` through those contexts rather than through a `BeanContext`, so marking only the `BeanContext`s left the web tier writable. The one late write to the app context (`app/BeanManager`) happens before this point, so it is unaffected.
- **`JavaCompReadOnlyTest`** (new): deploys a real application and asserts `bind`/`rebind`/`rename`/`unbind`/`createSubcontext`/`destroySubcontext` are all refused on `java:comp` and `java:app`, that nothing written becomes observable, and that pre-existing bindings survive.
- **`AppNamingReadOnlyTest`**: inverted `testAppNamingContextWritableByDefault` (it asserted the exact bug) into a read-only-by-default test, plus a separate test for the opt-out path.
## Verification
- `openejb-core` full suite: 4093 tests, the only 6 failures are pre-existing security-test failures reproduced on a clean `main` (unrelated to this change).
- Jakarta EE 11 Web Profile TCK `enterprise-beans-30` partition against a freshly built Plume distribution: the `naming/context` write assertions now pass in **both** the EJB and web (servlet / filtered-servlet / JSF) vehicles.
## Reviewer notes
- This is a container-wide default change. An application that writes to its own ENC after deployment would now be refused; the property above restores the old behaviour if needed.
- The TCK harness change to un-exclude these tests lives in the separate `apache/tomee-tck` repo and is not part of this PR.
- The TCK run surfaced a **separate, pre-existing** read-side bug (filed as TOMEE-4658): in web components TomEE hands out Tomcat's `org.apache.naming.NamingContext` instead of `IvmContext`, so `java:comp/env` lists extra `comp`/`module` entries and `close()` fails. It is orthogonal to this read-only fix and not addressed here.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Issue Time Tracking
-------------------
Worklog Id: (was: 1031915)
Remaining Estimate: 0h
Time Spent: 10m
> java:comp naming context accepts writes the Enterprise Beans spec requires it to refuse
> ---------------------------------------------------------------------------------------
>
> Key: TOMEE-4654
> URL: https://issues.apache.org/jira/browse/TOMEE-4654
> Project: TomEE
> Issue Type: Bug
> Reporter: Markus Jung
> Assignee: Markus Jung
> Priority: Major
> Time Spent: 10m
> Remaining Estimate: 0h
>
> The Enterprise Beans spec requires the java:comp context to be read-only inside a bean, and to throw {{OperationNotSupportedException}} on any write attempt against it. TomEE's naming context skips that check and lets bind, rebind, and rename calls through instead of refusing them.
> h2. Steps to reproduce / TCK reference
> Excluded in {{runner-webprofile/exclusions/enterprise-beans-30.txt}} in the apache/tomee-tck harness repo:
> * {{**/naming/context/*Test.java}}
> Once fixed, remove the matching lines and confirm the tests pass — each write attempt against java:comp must throw {{OperationNotSupportedException}}.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)