GcfJarLayout omits GcfJarLauncher$NestedUrlStreamHandlerFactory, causing NoClassDefFoundError under the GCF invoker
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 32/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- java
- Lĩnh vực
- build-system
Hướng nghiên cứu
Start in GcfJarLayout.writeLoadedClasses in the GCP adapter module: it copies only GcfJarLauncher.class to the repackaged jar root, while the launcher's static initializer now also references GcfJarLauncher$NestedUrlStreamHandlerFactory. Read that writer and the module's existing layout tests, then rebuild and run the invoker command from the report against a sample jar; done means the invoker starts and the function answers HELLO. Note that #1548 already proposes a change, so check it before starting.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
This is a follow-up to #1336. Its fix (present in 5.1.0) added a private static nested class, GcfJarLauncher$NestedUrlStreamHandlerFactory, to GcfJarLauncher. However, GcfJarLayout.writeLoadedClasses still copies only GcfJarLauncher.class to the root of the repackaged jar.
The Google Cloud Functions Java invoker loads GcfJarLauncher from the jar root, so initializing its static NESTED_URL_STREAM_HANDLER_FACTORY field fails because the nested class is not there:
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/cloud/function/adapter/gcp/GcfJarLauncher$NestedUrlStreamHandlerFactory
at org.springframework.cloud.function.adapter.gcp.GcfJarLauncher.<clinit>(GcfJarLauncher.java:43)
...
at com.google.cloud.functions.invoker.HttpFunctionExecutor.forClass(HttpFunctionExecutor.java:54)
at com.google.cloud.functions.invoker.runner.Invoker.servletForDeducedSignatureType(Invoker.java:381)
at com.google.cloud.functions.invoker.runner.Invoker.startServer(Invoker.java:302)
at com.google.cloud.functions.invoker.runner.Invoker.startServer(Invoker.java:248)
at com.google.cloud.functions.invoker.runner.Invoker.main(Invoker.java:131)
Caused by: java.lang.ClassNotFoundException: org.springframework.cloud.function.adapter.gcp.GcfJarLauncher$NestedUrlStreamHandlerFactory
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:593)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
... 14 more
A minimal reproducible example:
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>4.2.0</version>
<relativePath/>
</parent>
<groupId>com.example</groupId>
<artifactId>gcf-nested-handler-repro</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<java.version>21</java.version>
<spring-cloud-function.version>5.1.0</spring-cloud-function.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-adapter-gcp</artifactId>
<version>${spring-cloud-function.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<outputDirectory>target/deploy</outputDirectory>
</configuration>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-adapter-gcp</artifactId>
<version>${spring-cloud-function.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
src/main/java/com/example/demo/DemoApplication.java:
package com.example.demo;
import java.util.function.Function;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
@Bean
public Function<String, String> uppercase() {
return String::toUpperCase;
}
}
Steps to reproduce:
mvn clean package
mvn dependency:copy -Dartifact=com.google.cloud.functions.invoker:java-function-invoker:1.3.3 -DoutputDirectory=target
java -jar target/java-function-invoker-1.3.3.jar \
--classpath target/deploy/gcf-nested-handler-repro-0.0.1-SNAPSHOT.jar \
--target org.springframework.cloud.function.adapter.gcp.GcfJarLauncher \
--port 8080
Expected: the invoker starts and curl -X POST -H 'Content-Type: text/plain' -d hello http://localhost:8080/ returns HELLO.
Actual: the invoker exits immediately with the NoClassDefFoundError above.
- Ngôn ngữ chính
- Java
- Star
- 1.1k
- Fork
- 655
- Merge trung bình
- 4 giờ 54 phút
- Pull request đã merge (30 ngày)
- 10
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 spring-cloud/spring-cloud-function
-
ClassCastException with spring-cloud-function 4.3.6 when a field of type Set is deserializedĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
spring-cloud/spring-cloud-function#1542 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
spring-cloud/spring-cloud-function#1538 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Kotlin function wrapper treats empty input as no inputCó thể đã có người làm @seonwooj0810 đã nhận hôm nay. Đang mở5.0.x backport bug
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 30/100
spring-cloud/spring-cloud-function#1537 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Default JSON mapper collection limit is hard-coded and replaces all collection deserializationĐang mở5.0.x backport bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 22/100
spring-cloud/spring-cloud-function#1536 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
SmartCompositeMessageConverter fails with NullPointerException or ClassCastException in several conversion pathsCó thể đã có người làm @seonwooj0810 đã nhận 1 ngày trước. Đang mở5.0.x backport bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
spring-cloud/spring-cloud-function#1535 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của spring-cloud/spring-cloud-function
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 80/100
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 62/100
aphtech/brailleblaster#209 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
payers.csv writes QOLS_AVG as NaN for every payer that had no membersCó thể đã có người làm @DG47 đã nhận hôm nay. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 86/100
synthetichealth/synthea#1797 ·
Maintainer thường phản hồi trong vòng 19 ngày
-
build enhancement security
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
midhunhk/lib-aeapps#54 ·