Skip to content

fix(ojp-jdbc-driver): relocate all bundled third-party packages to prevent classpath pollution - #566

Merged
rrobetti merged 6 commits into
mainfrom
copilot/feasibility-analysis-ojp-jdbc-driver
Jul 30, 2026
Merged

fix(ojp-jdbc-driver): relocate all bundled third-party packages to prevent classpath pollution#566
rrobetti merged 6 commits into
mainfrom
copilot/feasibility-analysis-ojp-jdbc-driver

Conversation

Copilot AI commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

ojp-jdbc-driver was published as a shaded uber jar with no <relocations> configured. Every bundled class (io.grpc, io.netty, com.google.protobuf, com.google.common, Maven internals, etc.) landed at its original package coordinate, silently overriding whatever version the consumer already had on their classpath.

Changes

ojp-grpc-commons/pom.xml

  • Removed kr.motd.maven:os-maven-plugin from compile-scope <dependencies> — it is a build extension only and should never appear there. Its presence dragged the entire Maven plugin stack (org.apache.maven.*, org.codehaus.plexus.*, org.eclipse.sisu.*, javax.enterprise.*, etc.) into the driver's shaded jar.

ojp-jdbc-driver/pom.xml

  • jakarta.transaction-apiprovided scope; JTA is supplied by the container.
  • commons-lang3 added as an explicit compile dependency (was accidentally transitively available via kr.motd.maven).
  • plexus-utils added as an explicit test dependency (same root cause).
  • <artifactSet><excludes> drops annotation-only artifacts (jsr305, android-annotations, error_prone_annotations, j2objc-annotations, animal-sniffer-annotations, jspecify, listenablefuture) — no runtime value; their javax.annotation / android.annotation packages must not be embedded.
  • <filters> strips META-INF/*.SF/DSA/RSA signature files to prevent SecurityException at runtime.
  • <relocations> moves all remaining runtime packages under org.openjproxy.shaded.*:
<relocation>
    <pattern>io.grpc</pattern>
    <shadedPattern>org.openjproxy.shaded.io.grpc</shadedPattern>
</relocation>
<relocation>
    <pattern>io.netty</pattern>
    <shadedPattern>org.openjproxy.shaded.io.netty</shadedPattern>
</relocation>
<relocation>
    <pattern>io.perfmark</pattern>
    <shadedPattern>org.openjproxy.shaded.io.perfmark</shadedPattern>
</relocation>
<!-- covers protobuf, guava, gson, api-protos, and all other com.google.* -->
<relocation>
    <pattern>com.google</pattern>
    <shadedPattern>org.openjproxy.shaded.com.google</shadedPattern>
</relocation>
<relocation>
    <pattern>org.apache.commons</pattern>
    <shadedPattern>org.openjproxy.shaded.org.apache.commons</shadedPattern>
</relocation>

After this change the published jar contains no third-party classes at their original coordinates. Consumers using gRPC, Netty, Protobuf, or Guava independently will no longer see version conflicts from the driver.

…event classpath pollution

- Remove kr.motd.maven:os-maven-plugin compile-scope dependency from ojp-grpc-commons;
  it is a Maven build extension only and was incorrectly leaking Maven internals
  (org.apache.maven, org.codehaus.plexus, org.eclipse.sisu, javax.enterprise, etc.)
  onto every consumer's runtime classpath.
- Add explicit commons-lang3 dependency to ojp-jdbc-driver (previously obtained
  accidentally as a transitive dep via kr.motd.maven).
- Add explicit plexus-utils test dependency to ojp-jdbc-driver (same root cause).
- Change jakarta.transaction-api to provided scope; the JTA API is supplied by the
  container or consumer application and must not be bundled.
- Add <artifactSet><excludes> to drop annotation-only artifacts (jsr305,
  android-annotations, error_prone_annotations, j2objc-annotations,
  animal-sniffer-annotations, jspecify, listenablefuture) that have no runtime
  value and whose javax.annotation / android.annotation packages must not
  be included in the shaded jar.
- Add <filters> to exclude JAR signature files (META-INF/*.SF/DSA/RSA) from
  the shaded artifact to prevent SecurityException at runtime.
- Add <relocations> for all remaining runtime packages (io.grpc, io.netty,
  io.perfmark, com.google.*, org.apache.commons) under the
  org.openjproxy.shaded.* namespace, so they no longer conflict with any
  version of those same libraries the consumer already has on their classpath.

Fixes #565
Copilot AI changed the title [WIP] Analyze implications of publishing thin driver artifact for ojp-jdbc-driver fix(ojp-jdbc-driver): relocate all bundled third-party packages to prevent classpath pollution Jul 29, 2026
Copilot AI requested a review from rrobetti July 29, 2026 20:35
Copilot AI and others added 3 commits July 29, 2026 20:52
The ojp-server module uses org.apache.commons.lang3 in multiple source
files but the dependency was not declared in its pom.xml, causing a
compilation failure. The version is already managed in the parent POM
(3.18.0, overriding the transitive version to fix CVE-2025-48924).
…rver

The previous PR (3bbb92f) intentionally omitted commons-lang3 from the
ojp-server dependencies so it would not be bundled into the shaded JAR.
The previous fix attempt incorrectly re-added the dependency.

Instead, replace all StringUtils usages across 11 server source files
with JDK equivalents available since Java 11 (server targets Java 25):
- StringUtils.EMPTY           -> ""
- StringUtils.isBlank(x)      -> x.isBlank()
- StringUtils.isNotBlank(x)   -> !x.isBlank()
- StringUtils.isEmpty(x)      -> x.isEmpty()
- StringUtils.isNotEmpty(x)   -> !x.isEmpty()
- StringUtils.isNoneBlank(x)  -> !x.isBlank()

For Map.get() and JDBC metadata results that may return null, the
null-safe form (x != null && !x.isEmpty()) is used.
Proto-generated getters never return null so direct .isEmpty()/.isBlank()
is safe for all gRPC field accessors.
…actions-check

Resolving issues with GitHub Actions CI build and test
@rrobetti

Copy link
Copy Markdown
Contributor

@copilot Update relevant documentation including the e-book. Specially if now any dependency is expected to be provided and in which scenarios, application servers have more dependencies provided than web servers like tomcat, different frameworks might not have them. We test with Spring Boot, Quarkus, Micronaut and JakartaEE on Glassfish.

… frameworks

Document the provided-scope deps (slf4j-api, jakarta.transaction-api) and
shading behaviour introduced in the ojp-jdbc-driver shading PR:

- ebook chapter 7: new §7.1.1 covering provided deps, per-environment
  availability matrix, Tomcat/bare-servlet-container instructions, and
  classpath isolation explanation
- java-frameworks/README.md: top-level summary table with per-env notes
- spring-boot/README.md: Runtime Dependencies section (no action needed)
- quarkus/README.md: Runtime Dependencies section (no action needed)
- micronaut/README.md: Runtime Dependencies section with per-config table
- jakarta-ee/README.md: Runtime Dependencies section covering GlassFish,
  WildFly, Open Liberty, TomEE and plain Tomcat with explicit snippets

Copilot AI commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Update relevant documentation including the e-book. Specially if now any dependency is expected to be provided and in which scenarios, application servers have more dependencies provided than...

Documentation updated in commit 2b65aae (docs: add runtime dependency and classpath isolation guidance for all frameworks).

What was added:

E-book chapter 7 — new §7.1.1 "Runtime Dependencies and Classpath Isolation"

  • Explains the two provided-scope dependencies (slf4j-api, jakarta.transaction-api) and what "provided" means
  • Per-environment availability matrix covering Spring Boot, Quarkus, Micronaut, Jakarta EE application servers (GlassFish/Payara, WildFly, Open Liberty, TomEE), Apache Tomcat, and Jetty/Undertow
  • Maven snippets for Tomcat and bare servlet containers (the scenario that needs manual additions)
  • Classpath isolation section explaining the org.openjproxy.shaded.* relocation and why it matters

Per-framework README updates:

Guide Summary
Spring Boot No action needed — spring-boot-starter-logging and spring-tx supply both deps automatically
Quarkus No action needed — JBoss Logging bridge and quarkus-narayana-jta cover both deps
Micronaut No action needed when using micronaut-data or micronaut-transaction; explicit addition required only for XA without those extensions
Jakarta EE Detailed per-server table (GlassFish/Payara need SLF4J added; WildFly/Open Liberty/TomEE are fine; Tomcat needs both deps added explicitly)
java-frameworks/README.md Added top-level summary table so the situation is clear before users dive into any specific guide

@sonarqubecloud

Copy link
Copy Markdown

@rrobetti
rrobetti marked this pull request as ready for review July 30, 2026 01:45
@rrobetti
rrobetti merged commit d22206a into main Jul 30, 2026
1 check passed
@rrobetti
rrobetti deleted the copilot/feasibility-analysis-ojp-jdbc-driver branch July 30, 2026 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ojp-jdbc-driver ships an unrelocated shaded uber jar, polluting consumer classpaths

2 participants