Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

AddJaxwsRuntime blindly injects com.sun.xml.ws:jaxws-rt into projects using Apache CXF

Đang mở
#1,314 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java
Lĩnh vực
backend

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ả

bug

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.500
  • rewrite-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

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của openrewrite/rewrite-migrate-java

Tất cả issue của openrewrite/rewrite-migrate-java

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.