1---2name: microprofile-server3description: Architecture and coding rules for long-running Java MicroProfile / Jakarta EE server applications — BCE layering, business components (BC), JAX-RS resources, CDI, JSON-P, testing (unit/integration/system), and Maven project structure. Use when creating, generating, scaffolding, writing, or reviewing code, resources, entities, boundaries, or business components in MicroProfile server projects. Not for serverless deployments.4---56## Composition7- compose with `java-conventions` for all language-level Java rules (syntax, style, naming, visibility, interfaces/classes, methods/lambdas, streams/collections, exceptions, comments/JavaDoc)8- this skill specializes only the MicroProfile / Jakarta EE server context — it does not restate language-level rules910## Dependencies11- prefer dependencies in this order: Java SE, MicroProfile, Jakarta EE1213## Exceptions (JAX-RS)14- in JAX-RS projects, inherit from WebApplicationException for custom exceptions15- use explicit exceptions like BadRequestException for Response.Status.BAD_REQUEST16- throw explicit WebApplicationException subclasses (e.g. BadRequestException, NotFoundException) rather than constructing Response objects inline — they are automatically mapped to the correct HTTP status by the JAX-RS runtime1718## BCE/ECB Architecture19- structure code using the Boundary Control Entity (BCE/ECB) pattern20- package structure: [ORGANIZATION_NAME].[PROJECT_NAME].[COMPONENT_NAME].[boundary|control|entity]21- top level package reflects the application responsibility or name22- suggest renaming the top level [PROJECT_NAME] package when it does not reflect the project's name or responsibility23- business components are children of top level package, named after their responsibilities24- a BC may represent a domain concept or a shared concern; both are valid when the responsibility has a name and is reused across the application25- boundary, control, entity packages are only allowed in business components26- a BC does not need every layer; a BC may consist of only a control layer when its responsibility is procedural and consumed by other BCs27- not every BCE component needs a dedicated boundary package; control package contents can be accessed directly28- prefer a dedicated BC over the root application package when a shared concern carries domain or protocol semantics, exposes more than one operation, or is expected to grow29- reserve the root application package for trivial single-class plumbing with no business semantics and no protocol coupling30- do not explain the BCE pattern in documentation3132## Boundary Layer33- keep coarse-grained classes in the boundary package34- place facades in the boundary package35- health checks must be placed in the boundary package36- @Transactional is only allowed in boundary layer37- if there is no Boundary stereotype, use ApplicationScope instead3839## Control Layer40- implement procedural business logic in the control package4142## Entity Layer43- maintain domain objects, data classes, and entities in the entity package44- entities maintain state and corresponding behavior45- model value objects as enums46- direct references between entities from independent BCs are allowed, but always aim for Maximal Cohesion and Minimal Coupling between BCs47- if a relation exists in the database (e.g. JPA foreign key), the entities must carry a corresponding reference (id field or association); the DB schema is the source of truth48- excessive cross-BC references or shared configuration is a refactoring signal — split, merge, or rebalance the BCs to restore cohesion4950## Components51- create new components with minimal business logic and essential fields only5253## JavaDoc (MicroProfile/Jakarta EE)54- follow links in JavaDoc to external specifications and use them for code generation55- use popular, also funny, technical terms from the Java SE, MicroProfile and Jakarta EE ecosystems as examples in unit tests and javadoc5657## README Guidelines58- write brief, 'to the point' README.md files for advanced developers59- use precise and concise language; avoid generic adjectives like "simple", "lightweight"60- do not include detailed project structure (file/folder listings); high-level module descriptions are acceptable61- never list REST resources in READMEs62- if modules are listed, provide links63- do not use "Orchestrates" term; use more specific alternatives6465## Integration Tests66- integration tests end with IT suffix and are executed by the failsafe maven plugin (no configuration necessary)6768## System Tests (ST)69- system tests are created in a dedicated Maven module ending with "-st"70- use microprofile-rest-client for testing JAX-RS resources71- REST client interfaces: src/main/java of the -st module72- test classes: src/test/java of the -st module73- name client interfaces after the resource with "Client" suffix (e.g., GreetingsResource -> GreetingsResourceClient)74- RegisterRestClient configKey: "service_uri"75- STs end with "IT" suffix76- do not use RestAssured. Write e2e test in the -st module77- execute system tests after every major change to the service module78- in PoC mode (user-activated), system test execution is skipped7980## JAX-RS81- resources should be named in plural (e.g., SpeakersResource not SpeakerResource)82- @Consumes and @Produces should be declared on class-level83- do not implement business logic in JAX-RS resources; delegate instead84- prefer returning JAX-RS Response over JsonObject in resources85- do not create new "@RegisterRestClient(configKey," - reuse existing8687## JSON Serialization (JSON-P)88- prefer JSON-P over JSON-B89- record entities should ship with toJSON method returning a JSON-P object90- always map JSON-P in the boundary to entities91- create record entities from JSON-P JsonObject in static method: fromJSON(JsonObject json)9293## Project Management94- always ask before changing pom.xml95- on opening existing projects, load AGENTS.md (if present) before making changes96- do not create or change any files on opening existing projects; stop after initialization and wait for instructions97- do not generate code initially in an empty project98- Maven pom.xml must not be created for Java 25 CLI applications99- never use quarkus-hibernate-validator100- create metrics and observability features with OTEL / opentelemetry