Skip to content

TP bring-up: missing JAXB Atom marshaller, narrow component scan, and broader OAuth2-client wiring gaps #146

Closed

Description

@dfcoffin

Summary

The Third Party module cannot complete Spring context initialization against the current dev-mysql profile. A narrow chain of bean-wiring gaps surfaces when bringing TP up locally against a fresh DC + AS pair (in support of #122 PR C4 manual testing). The deeper architectural issue is that TP is not currently a functional ESPI third party — its OAuth2 client config, Atom marshalling pipeline, and Notification Endpoint receiver path have not been brought to a working state in the Spring Boot 4 / Spring 7 migration.

Priority context: Per the project lead, DC API completion is upstream of this work. TP cannot meaningfully exercise the OAuth2 + ESPI resource flow without a complete DC API surface (the BatchList notifications, the Subscription resource feeds, the Customer/PII resource feeds, etc. that TP would receive). File a focused DC API audit/completion issue first; this TP issue should be triaged after DC stabilizes.

What's already been observed locally

Encountered in this order while running mvn spring-boot:run -Dspring-boot.run.profiles=dev-mysql:

  1. Missing UsagePointMapper bean — TP's @SpringBootApplication.scanBasePackages excluded org.greenbuttonalliance.espi.common.mapper, so MapStruct-generated mapper impls were not registered. Half-fix in PR Phase 2.0 — Stand up auth-server in dev with opaque tokens + subscription-bound introspection (Phase 2 precursor) #122 PR C4 (broadened scan to org.greenbuttonalliance.espi.common).

  2. Missing EspiIdGeneratorService bean — same root cause; lives in org.greenbuttonalliance.espi.common.service (not .service.impl). Resolved by the same scan broadening in PR C4.

  3. Missing Jaxb2Marshaller bean named atomMarshaller — ResourceRESTRepositoryImpl (and several other resource repos) @Autowired a @Qualifier("atomMarshaller") Jaxb2Marshaller. No @Bean definition currently exists for it in TP, openespi-common, or any autoconfiguration on the classpath. PR C4 does NOT fix this — manual testing stops here.

What likely remains under the surface

The pattern above (TP discovering missing collaborator beans one-at-a-time during context init) suggests the migration from the pre-Spring-Boot-4 codebase left TP partially wired. Likely items to audit:

  • Atom feed marshalling pipeline — Jaxb2Marshaller + ESPI/Atom JAXB context configuration, currently undefined.
  • Notification Endpoint — TP's REST endpoint that receives BatchList from DC at grant-completion. Status: unverified, likely also missing security + Jaxb plumbing.
  • OAuth2 client config — TP's application.yml references client-id: third_party and callback URIs; needs end-to-end verification against AS's current RegisteredClient definition (AuthorizationServerConfig.java:278-301).
  • Resource fetching layer — ResourceRESTRepositoryImpl, UsagePointRESTRepositoryImpl, etc.; whether they actually round-trip against DC's current Atom feed endpoints.
  • JPA layer — TP has 24 repository interfaces; need to confirm the entity scan and database schema (TP currently runs with flyway: 0 migrations against a thirdparty MySQL DB, suggesting either it's relying on Hibernate ddl-auto=update or it doesn't actually persist anything that matters yet).

Reproduction (current state)

# Per PR C4 README instructions
cd openespi-thirdparty
mvn spring-boot:run -Dspring-boot.run.profiles=dev-mysql

Fails with:

APPLICATION FAILED TO START
Field marshaller in org.greenbuttonalliance.espi.thirdparty.repository.impl.ResourceRESTRepositoryImpl
required a bean of type 'org.springframework.oxm.jaxb.Jaxb2Marshaller' that could not be found.
The injection point has the following annotations:
  - @org.springframework.beans.factory.annotation.Autowired(required=true)
  - @org.springframework.beans.factory.annotation.Qualifier("atomMarshaller")

Recommended approach (after DC API work lands)

  1. Audit the full TP bean dependency graph at context-init time — identify every @Autowired collaborator from TP code into openespi-common and confirm each has a definition path. Don't fix one-at-a-time; produce a list, then plan.
  2. Define the missing atomMarshaller Jaxb2Marshaller bean — likely belongs in either openespi-common's Spring config or a new TP @Configuration class. Aligns with whatever JAXB context the existing BaseExportService family uses on DC.
  3. End-to-end smoke the OAuth2 customer flow: TP root → AS /oauth2/authorize → DC consent screen → token exchange → TP fetches a UsagePoint feed. (Blocked on the DC API completion above.)
  4. Notification Endpoint smoke test — DC pushes a BatchList to TP at grant-completion; TP processes and persists. (Likely also blocked on DC.)
  5. Remove PR Phase 2.0 — Stand up auth-server in dev with opaque tokens + subscription-bound introspection (Phase 2 precursor) #122 PR C4's TP scan-broadening workaround once the proper wiring is in place — or keep it as the canonical wide-scan pattern if that matches the project's preference.

Out of scope for this issue

Acceptance

  • Document the architectural intent for TP (is it a reference OAuth2 client for ESPI integrators? a development harness for DC API testing? something else?).
  • mvn spring-boot:run -Dspring-boot.run.profiles=dev-mysql boots TP cleanly against a working DC + AS.
  • Browser flow: TP root → OAuth2 authorize → DC screens → token exchange → TP can fetch and render at least one ESPI resource.
  • DC-to-TP Notification Endpoint receives and processes a BatchList push.
  • PR Phase 2.0 — Stand up auth-server in dev with opaque tokens + subscription-bound introspection (Phase 2 precursor) #122 PR C4's TP scan-broadening workaround is either confirmed correct and kept, or replaced with the project's preferred pattern.

Activity

  1. added
    bugSomething isn't working
    infrastructureCI, build, deployment, or developer tooling
    blockingBlocks other work or CI
    on Jun 3, 2026
  2. added 2 commits that reference this issue on Jun 3, 2026
  3. dfcoffin commented on Jun 7, 2026

    @dfcoffin
    ContributorAuthor

    Bring-up findings (manual AS+DC+TP launch, 2026-06-06)

    Confirmed the TP context-init wiring chain by launching all three servers locally (MySQL on 3306). Progress on the chain:

    • ✅ atomMarshaller Jaxb2Marshaller bean — defined in PR fix: local sandbox bring-up — DC↔AS introspection alignment + TP atomMarshaller (#146) #170 (JaxbMarshallingConfiguration). TP now advances past this gap.
    • ❌ Next gap: ResourceRepository — ResourceRESTServiceImpl.resourceRepository requires org.greenbuttonalliance.espi.common.repositories.usage.ResourceRepository, which is a custom interface with NO implementation anywhere (no ResourceRepositoryImpl, no implements ResourceRepository). The resource-fetch layer was never built. This is the substantive next step for TP bring-up.
    • Likely further gaps after that (WebClient wiring, import/fetch-back, the unimplemented ResourceRepository methods like findAllIdsByXPath). Per "DC API completion is upstream of TP," these stay deferred.

    Also note (not TP): the DC↔AS dev introspection config was misaligned (DC→:8080 / unseeded datacustodian client) — fixed in #170 so the sandbox introspects out of the box. And DC collection GETs marshal a raw List (500) — fixed by the #119 E-phase entry/feed assembly.

    Runbook for local 3-server bring-up captured in the working notes.

  4. added 5 commits that reference this issue on Jun 7, 2026
  5. dfcoffin commented on Nov 14, 2026

    @dfcoffin
    ContributorAuthor

    Update from a local run, 2026-11-14 (local H2 profile)

    Progress: the Third Party now starts with -Dspring-boot.run.profiles=local in about 5.7 s on port 8082, and the atomMarshaller start-up failure described above no longer happens. /, /home and /login render. The navigation-link problems are filed separately as #235.

    OAuth client configuration vs. the AS's seeded third_party client. This is the "needs end-to-end verification" item above, now checked:

    TP application.yml (datacustodian-monthly/-daily/-admin) AS seeded third_party (AuthorizationServerConfig) Result
    Client secret ${OAUTH2_CLIENT_SECRET:secret} {noop}tp-secret Token exchange would fail with invalid_client
    Redirect URI http://localhost:8082/ThirdParty/login/oauth2/code/<registrationId> …:8080/DataCustodian/oauth/callback, …:9090/ThirdParty/oauth/callback /oauth2/authorize returns 400
    Scope openid,profile,FB=… openid/profile registered, but OIDC is restricted since #134 invalid_scope: OpenID Connect 1.0 authentication requests are restricted.
    datacustodian-admin ThirdParty_Admin_Access via authorization_code n/a ESPI admin access normally uses client_credentials

    With the AS's own redirect URI and only the ESPI FB scope, /oauth2/authorize gets as far as the DC delegation step, then stops because of the new blocking issue #232.

    Suggested fixes:

    • Remove openid,profile from the TP scopes.
    • Point the AS seed's redirect URIs at TP's real …:8082/ThirdParty/login/oauth2/code/*, or make both sides configurable from one set of properties.
    • Make the AS seed secret and the TP default secret match for local development.
    • Switch datacustodian-admin to client_credentials.
  6. dfcoffin commented on Nov 16, 2026

    @dfcoffin
    ContributorAuthor

    TP sign-in is lost when a customer authorizes a Data Custodian (found in the #268 review)

    Since #268 (#249), the Third Party has its own form login: a customer signs in with a TP account (ROLE_USER), then authorizes a Data Custodian from the home page cards. DC authorization still runs through oauth2Login, and that is now a defect.

    What happens

    1. Customer customer signs in with form login and has ROLE_USER.
    2. They choose Authorize Monthly Access (/oauth2/authorize/monthly → /oauth2/authorization/datacustodian-monthly) and approve at the DC.
    3. The callback /login/oauth2/code/datacustodian-monthly is handled by OAuth2LoginAuthenticationFilter. It replaces the session's authentication with an OAuth2AuthenticationToken, whose principal is the DC user (user-name-attribute: uuid) and whose authorities are OAUTH2_USER and SCOPE_*.
    4. The customer has lost ROLE_USER. feat(thirdparty): username/password login matching the Data Custodian design (#249) #268 also turned on @EnableMethodSecurity, so customer pages with @PreAuthorize("hasRole('ROLE_USER')") (UsagePointController, DataCustodianListController) now return 403.
    5. The authorized client (access token) is saved under the DC principal's name, not the TP account, so it can't be tied back to the TP customer.
    6. oauth2Login also calls the user-info-uri. That points at a DC ESPI resource and is not OIDC user info. If the call fails, the login fails and the token is not kept.

    Also: oauth2Login signs in visitors who have no TP account (found in the #270 review). OAuth2AuthorizationRequestRedirectFilter and OAuth2LoginAuthenticationFilter run before the authorization rules. So an anonymous visitor can open /oauth2/authorization/datacustodian-monthly directly, approve at the Data Custodian, and return signed in to the Third Party as the OAuth2 principal, without a TP account and without the TP login page. They can then open every page that requires only authenticated() (anyRequest().authenticated() in SecurityConfiguration). Role-gated pages stay closed, because the token carries only OAUTH2_USER/SCOPE_*. This was already true before #268, when oauth2Login was the only sign-in. Moving to oauth2Client() removes it: OAuth2AuthorizationCodeGrantFilter never authenticates anyone, and the authorization endpoints can then require a signed-in TP customer.

    Proposed fix: use .oauth2Client() instead of .oauth2Login() for the datacustodian-* registrations. OAuth2AuthorizationCodeGrantFilter completes the authorization-code grant and stores the authorized client for the current (form-login) principal without changing it, and it doesn't call user info. The callback redirect URIs and the AS seed's registered redirect URIs need to match whatever callback path is chosen. Link the stored Authorization and Subscription to the TP RetailCustomerEntity (AuthorizationEntity.retailCustomer), as the decision comment on #249 describes.

    Related, from the same review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    blockingBlocks other work or CIbugSomething isn't workinginfrastructureCI, build, deployment, or developer tooling

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions