|
| 1 | +# Bringing up the live backends (Sobek :37999 + Shepet :37998) |
| 2 | + |
| 3 | +Live mode needs **Sobek** for GraphQL/CRUD. The **Autosys import** flow additionally needs |
| 4 | +**Shepet** on :37998 (hathor's import dialog fetches `…/services/autosys?registrationNumber=…` |
| 5 | +from Shepet). PostGIS (:37433, Sobek's DB) comes up via `docker compose up` in `sobek/`. |
| 6 | + |
| 7 | +Both are **Java 21** Spring Boot apps. Build under JDK 21, run in the background, then confirm a |
| 8 | +`401` on the secured endpoints (= up + serving; the live e2e supplies a real partner JWT via the |
| 9 | +login handoff). Recipes below were verified end-to-end on 2026-06-22. |
| 10 | + |
| 11 | +## Recipe |
| 12 | + |
| 13 | +```bash |
| 14 | +J=~/.sdkman/candidates/java/21.0.10-oracle # NOT the default 26 — see snag 1 |
| 15 | +MVN=~/.sdkman/candidates/maven/current/bin/mvn # `mvn` is a shell-fn alias; use the real binary |
| 16 | + |
| 17 | +# 0. PostGIS (if not already on :37433) |
| 18 | +( cd ~/entur/sobek && docker compose up -d ) |
| 19 | + |
| 20 | +# 1. Build Sobek FIRST — it installs sobek-common into .m2 that Shepet compiles against |
| 21 | +( cd ~/entur/sobek && JAVA_HOME=$J $MVN clean install -DskipTests ) |
| 22 | +( cd ~/entur/shepet && JAVA_HOME=$J $MVN clean install -DskipTests ) # AFTER sobek — see snag 2 |
| 23 | + |
| 24 | +# 2. Run Sobek (3 local profiles), background |
| 25 | +( cd ~/entur/sobek && JAVA_HOME=$J $MVN -pl sobek-app spring-boot:run \ |
| 26 | + -Dspring-boot.run.profiles=local,local-blobstore,local-changelog ) |
| 27 | + |
| 28 | +# 3. Run Shepet (local profile), background — env mapping + completed internal client, see snag 3 |
| 29 | +( cd ~/entur/shepet && JAVA_HOME=$J \ |
| 30 | + AUTOSYS_API_APIKEY="$AUTOSYS_API_API_KEY" \ |
| 31 | + SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_INTERNAL_PROVIDER=internal \ |
| 32 | + SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_INTERNAL_AUTHORIZATION_GRANT_TYPE=client_credentials \ |
| 33 | + SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_INTERNAL_TOKEN_URI=https://partner.dev.entur.org/oauth/token \ |
| 34 | + $MVN -pl shepet-app spring-boot:run -Dspring-boot.run.profiles=local ) |
| 35 | +``` |
| 36 | + |
| 37 | +Verify (don't trust "Started … in Ns" alone — check the ports answer): |
| 38 | + |
| 39 | +```bash |
| 40 | +ss -ltn | grep -E ':37999|:37998' # both listening |
| 41 | +curl -so/dev/null -w '%{http_code}\n' -XPOST localhost:37999/services/vehicles/graphql \ |
| 42 | + -H 'Content-Type: application/json' -d '{"query":"{__typename}"}' # 401 = up, secured |
| 43 | +curl -so/dev/null -w '%{http_code}\n' 'localhost:37998/services/autosys?registrationNumber=A-1' # 401 = up, secured |
| 44 | +curl -so/dev/null -w '%{http_code}\n' localhost:37998/health/ready # 200 = permitAll health |
| 45 | +``` |
| 46 | + |
| 47 | +`401` is the **healthy** state — both apps require a Bearer token. `000`/connection-refused = not up. |
| 48 | + |
| 49 | +## Snags (each cost real time the first time) |
| 50 | + |
| 51 | +1. **JDK 26 default breaks the build.** SDKMAN default is `26-oracle`; both projects need 21 |
| 52 | + (`<java.version>21</java.version>`). Under 26 the superpom's JaCoCo 0.8.13 dies with |
| 53 | + `Unsupported class file major version 70`. Force `JAVA_HOME=~/.sdkman/candidates/java/21.0.10-oracle` |
| 54 | + for every build/run. Also: `mvn` is a zsh shell-function alias (`mvn-or-mvnw`) that won't resolve |
| 55 | + in non-interactive bash — call `~/.sdkman/candidates/maven/current/bin/mvn` directly. |
| 56 | + |
| 57 | +2. **Sobek ↔ Shepet cross-repo API drift.** Both pin `sobek.version=1.0.1-SNAPSHOT` (a *local* |
| 58 | + SNAPSHOT), and Sobek `main` evolves independently. On 2026-06-22 Sobek had renamed |
| 59 | + `KeyValuesHelper.AddToKeyValues` → `SetToKeyValues` (commit "Move functions used in Autosys to |
| 60 | + sobek-common" + "Support mapping keyvalues both ways"); Shepet's HEAD still called the old name at |
| 61 | + 3 sites in `shepet-app/.../mapping/MapperService.java`. Building Sobek installs the renamed API |
| 62 | + into `.m2`, so Shepet then fails to compile (`cannot find symbol AddToKeyValues`). The new |
| 63 | + `SetToKeyValues(DataManagedObjectStructure,…)` is a type-safe, semantics-preserving superset |
| 64 | + (upsert; `VehicleType extends DataManagedObjectStructure`), so the local unblock is a mechanical |
| 65 | + rename of those call sites. **This is a real drift that wants a Shepet PR — do NOT commit the |
| 66 | + rename from a hathor session; treat it as an uncommitted local workaround and flag it.** When the |
| 67 | + build breaks on a `sobek-common` symbol, suspect this first; build Sobek *before* Shepet so Shepet |
| 68 | + compiles against the fresh jar. |
| 69 | + |
| 70 | +3. **Shepet's OAuth2 `internal` client fails startup with partial config.** The env supplies the |
| 71 | + client *credentials* (`SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_INTERNAL_CLIENT_ID` / `…_SECRET`) |
| 72 | + but not the provider/token-uri, so Boot's oauth2-**client** autoconfig builds a registration named |
| 73 | + `internal` with no provider → `Provider ID must be specified for client registration 'internal'` |
| 74 | + at startup. That client is only used by the **baba** role-extractor path |
| 75 | + (`@ConditionalOnProperty shepet.security.role.assignment.extractor=baba`); the default is `jwt`, |
| 76 | + so it's never used at runtime — it just has to *construct*. Supply the three missing |
| 77 | + `…INTERNAL_PROVIDER` / `…INTERNAL_AUTHORIZATION_GRANT_TYPE` / `…PROVIDER_INTERNAL_TOKEN_URI` env |
| 78 | + vars (recipe above) and it boots. Also note the Autosys key env var name mismatch: the env holds |
| 79 | + `AUTOSYS_API_API_KEY` but the property reads `${AUTOSYS_API_APIKEY}` — remap on launch. |
| 80 | + |
| 81 | +4. **These are session-scoped background processes.** Started via the agent's background Bash, they |
| 82 | + die when the session/processes are killed. Re-run steps 2–3 (build artifacts persist in `.m2`) to |
| 83 | + bring them back; no rebuild needed unless source changed. |
| 84 | + |
| 85 | +## Secrets |
| 86 | + |
| 87 | +The three Shepet secrets are already exported in the shell env (`AUTOSYS_API_API_KEY`, partner |
| 88 | +`SHEPET_OAUTH2_RESOURCESERVER_AUTH0_ENTUR_PARTNER_JWT_{ISSUER_URI,AUDIENCE}`, plus the internal |
| 89 | +client id/secret). **Never echo their values into chat, commits, or this file** — reference them by |
| 90 | +env-var name only. |
0 commit comments