AddJaxwsRuntime blindly injects com.sun.xml.ws:jaxws-rt into projects using Apache CXF
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 55/100
Hướng nghiên cứu
Start by reading AddJaxwsRuntime.java and the AddJaxwsRuntimeMaven recipe, then inspect its tests for dependency detection. Reproduce with the provided Maven project using Apache CXF's cxf-rt-frontend-jaxws dependency. Done means the recipe avoids adding com.sun.xml.ws:jaxws-rt when an alternative JAX-WS runtime is already present, with a test covering that case.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I checked out all relevant OpenRewrite repo's, fed the AI with existing recipe name and a very careful description. Antigravity with Vertex / Gemini was then tasked to check and test. .Also to create a ticket for it, using your default template. The result is shown beneath.
What version of OpenRewrite are you using?
rewrite-maven-plugin: 6.500rewrite-migrate-java: 3.49.0- Recipe:
org.openrewrite.java.migrate.javax.AddJaxwsRuntime(AddJaxwsRuntimeMaven)
How are you running OpenRewrite?
Maven plugin on a multi-module Maven project running UpgradeToJava21 (or UpgradeToJava11 / UpgradeToJava17):
What is the smallest, simplest way to reproduce the problem?
Create a project that uses Apache CXF for JAX-WS web services:
pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.sample</groupId>
<artifactId>cxf-sample</artifactId>
<version>1.0.0</version>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>3.5.5</version>
</dependency>
</dependencies>
</project>
Run:
mvn rewrite:run -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-migrate-java:LATEST -Drewrite.activeRecipes=org.openrewrite.java.migrate.javax.AddJaxwsRuntime
What did you expect to see?
pom.xml should not be modified.
Apache CXF provides its own JAX-WS implementation and runtime. It does not require or use the Sun/Metro reference implementation (com.sun.xml.ws:jaxws-rt).
What did you see instead?
OpenRewrite injects Sun's JAX-WS runtime into pom.xml:
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.3.x</version>
<scope>provided</scope>
</dependency>
Root Cause
In AddJaxwsRuntime.java (AddJaxwsRuntimeMaven), the recipe checks whether jakarta.xml.ws:jakarta.xml.ws-api exists in transitive dependencies. If found, it checks only whether com.sun.xml.ws:jaxws-rt is absent.
Because Apache CXF brings in jakarta.xml.ws-api transitively, AddJaxwsRuntimeMaven assumes the project lacks a JAX-WS runtime and blindly injects com.sun.xml.ws:jaxws-rt.
This causes classpath pollution and conflicting JAX-WS SPI provider entries (META-INF/services/javax.xml.ws.spi.Provider) between Apache CXF and Sun's runtime.
Proposed Fix
Before adding com.sun.xml.ws:jaxws-rt, check whether an alternative JAX-WS runtime is already present on the classpath (e.g. org.apache.cxf:cxf-rt-frontend-jaxws, org.apache.cxf:cxf-rt-transports-http, or Spring WS).
What is the full stack trace of any errors you encountered?
N/A (semantic defect resulting in conflicting dependency injection).
- Ngôn ngữ chính
- Java
- Star
- 159
- Fork
- 130
- Merge trung bình
- 7 giờ 49 phút
- Pull request đã merge (30 ngày)
- 60
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của openrewrite/rewrite-migrate-java
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
openrewrite/rewrite-migrate-java#1305 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
openrewrite/rewrite-migrate-java#1319 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
openrewrite/rewrite-migrate-java#1310 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
openrewrite/rewrite-migrate-java#1307 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 55/100
openrewrite/rewrite-migrate-java#1304 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của openrewrite/rewrite-migrate-java
Issue tương tự
-
enhancement web-ui
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
jenkinsci/jenkins#27583 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
apache/rocketmq-dashboard#7302 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
area: android good first issue help wanted testing
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Gautam-aman/ResQNet#56 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation hermes-queue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
chrisalunlloyd2-sudo/mindpalace#294 ·
Maintainer thường phản hồi trong vòng 1 ngày