[ 
https://issues.apache.org/jira/browse/TOMEE-4716?focusedWorklogId=1044387&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1044387
 ]

ASF GitHub Bot logged work on TOMEE-4716:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 28/Sep/26 12:57
            Start Date: 28/Sep/26 12:57
    Worklog Time Spent: 10m 
      Work Description: jungm opened a new pull request, #2960:
URL: https://github.com/apache/tomee/pull/2960

   Fixes [TOMEE-4716](https://issues.apache.org/jira/browse/TOMEE-4716): with 
the MicroProfile distribution, a webapp that declares a JAX-RS `Application` 
listing its classes has no `/health`, `/health/live`, `/health/ready` or 
`/health/started` (all 404); an `Application` listing nothing gets them under 
its own path, e.g. `/api/health`.
   
   `MicroProfileHealthChecksEndpoint` only reached a webapp through class 
scanning (`WebAppInfo.restClass`), and `RESTService` only deploys scanned 
classes into the default application (no `Application` declared) or into an 
`Application` that lists nothing. Since TOMEE-3729 a declared `Application` 
deploys exactly the classes it lists, so the endpoint went with the rest of the 
scanned classes. [MicroProfile Health 
4.0.1](https://download.eclipse.org/microprofile/microprofile-health-4.0.1/microprofile-health-spec-4.0.1.html#_rationale)
 describes the endpoints as representing the entire runtime, not one JAX-RS 
application.
   
   `TomEEMicroProfileListener` now registers the endpoint in a new 
`WebAppInfo.containerRestClass` set, and `RESTService` deploys those classes at 
the context root: as their own internal application when the webapp declares 
`Application` subclasses, as part of the default application otherwise, and in 
the per-class fallback deployment. TOMEE-3729's rule is unchanged, and the 
existing removal of the endpoint when a servlet is mapped to `/*` still applies.
   
   New `HealthEndpointTest` in `tomee-microprofile-itests` deploys an 
`@ApplicationPath("/api")` application once listing its resource and once 
listing nothing. Both fail with 404 on `/test/health` without the fix and pass 
with it. The rest of `tomee-microprofile-itests`, `openejb-cxf-rs` (115 tests) 
and the MicroProfile Health TCK (28 tests) pass.
   




Issue Time Tracking
-------------------

            Worklog Id:     (was: 1044387)
    Remaining Estimate: 0h
            Time Spent: 10m

> MicroProfile Health endpoints are not deployed when the webapp declares a 
> JAX-RS Application subclass
> -----------------------------------------------------------------------------------------------------
>
>                 Key: TOMEE-4716
>                 URL: https://issues.apache.org/jira/browse/TOMEE-4716
>             Project: TomEE
>          Issue Type: Bug
>            Reporter: Markus Jung
>            Priority: Major
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> TomEEMicroProfileListener gets {{MicroProfileHealthChecksEndpoint}} into a 
> webapp only through class scanning ({{WebAppInfo.restClass}}). RESTService 
> deploys scanned classes in just two cases: in the default application when 
> the webapp declares no {{Application}} subclass, and inside a declared 
> {{Application}} whose {{getClasses()}} and {{getSingletons()}} are empty.
> So the health endpoint depends on how the application configures JAX-RS:
> * An {{Application}} that lists its classes (since TOMEE-3729 only those are 
> deployed) loses {{/health}}, {{/health/live}}, {{/health/ready}} and 
> {{/health/started}} entirely; all four answer 404.
> * An {{Application}} that lists nothing deploys the endpoints under its own 
> path, e.g. {{/api/health}} for {{@ApplicationPath("/api")}}, instead of the 
> context root.
> MicroProfile Health 4.0.1, section 
> [Rationale|https://download.eclipse.org/microprofile/microprofile-health-4.0.1/microprofile-health-spec-4.0.1.html#_rationale],
>  describes the endpoints as representing the runtime rather than one JAX-RS 
> application:
> bq. The MicroProfile Health architecture consists of three /health/ready, 
> /health/live and /health/started endpoints in a MicroProfile runtime that 
> respectively represent the readiness, the liveness and the startup health of 
> the entire runtime.
> Declaring an {{Application}} is the portable way to configure JAX-RS (Jakarta 
> RESTful Web Services 4.0, section [2.3.2 
> Servlet|https://jakarta.ee/specifications/restful-ws/4.0/jakarta-restful-ws-spec-4.0.html#servlet]),
>  so it must not switch the health endpoints off or move them.
> Reproducer: a WAR with {{@ApplicationPath("/api")}} and {{getClasses()}} 
> returning one resource, deployed on the MicroProfile distribution; {{GET 
> /[context]/health}} returns 404.
> Fix: container-contributed resources are tracked separately from scanned 
> application classes ({{WebAppInfo.containerRestClass}}) and deployed in their 
> own internal application at the context root, whatever {{Application}} 
> subclasses the webapp declares. TOMEE-3729's rule that an {{Application}} 
> only deploys the classes it lists is unchanged.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to