GoogleCloudPlatform / GoogleCloudPlatform/spring-cloud-gcp

spring data spanner entities and repositories need to be public when compiling in graalvm native images

Open
#3,324 1 comment 0 reactions 0 assignees View on GitHub
priority: p3 type: bug
Dominant language
Java
Stars
551
Forks
349
Avg merge
1d 13h
Merged PRs (30d)
14

Description

for some reason the graalvm native image AOT compilation fails if the google cloud data spanner entities and repositories are nto `public`. this occurs when i go to start.spring.io and build a project with the following `pom.xml`:

```

4.0.0

org.springframework.boot
spring-boot-starter-parent
3.3.4


com.example
service
0.0.1-SNAPSHOT
service
Demo project for Spring Boot














21
1.0.0-M3
5.7.0
2023.0.3



org.springframework.boot
spring-boot-starter-web


com.google.cloud
spring-cloud-gcp-starter


com.google.cloud
spring-cloud-gcp-starter-pubsub


com.google.cloud
spring-cloud-gcp-starter-storage



org.springframework.ai
spring-ai-vertex-ai-gemini-spring-boot-starter


org.springframework.cloud
spring-cloud-stream


org.springframework.boot
spring-boot-starter-test
test



com.google.cloud
spring-cloud-gcp-starter-data-spanner






com.google.cloud
spring-cloud-gcp-vision







org.springframework.cloud
spring-cloud-dependencies
${spring-cloud.version}
pom
import


org.springframework.ai
spring-ai-bom
${spring-ai.version}
pom
import


com.google.cloud
spring-cloud-gcp-dependencies
${spring-cloud-gcp.version}
pom
import





org.graalvm.buildtools
native-maven-plugin


org.springframework.boot
spring-boot-maven-plugin





spring-milestones
Spring Milestones
https://repo.spring.io/milestone

false


```

here's the error log.

```
...
[INFO]
[INFO] --- resources:3.3.1:resources (default-resources) @ service ---
[INFO] Copying 1 resource from src/main/resources to target/classes
[INFO] Copying 1 resource from src/main/resources to target/classes
[INFO]
[INFO] --- compiler:3.13.0:compile (default-compile) @ service ---
[INFO] Recompiling the module because of changed source code.
[INFO] Compiling 3 source files with javac [debug parameters release 21] to target/classes
[INFO]
[INFO] --- resources:3.3.1:testResources (default-testResources) @ service ---
[INFO] skip non existing resourceDirectory /Users/jlong/Desktop/gcp-webinar/service/src/test/resources
[INFO]
[INFO] --- compiler:3.13.0:testCompile (default-testCompile) @ service ---
[INFO] Recompiling the module because of changed dependency.
[INFO] Compiling 1 source file with javac [debug parameters release 21] to target/test-classes
[INFO]
[INFO] --- surefire:3.2.5:test (default-test) @ service ---
[WARNING] Parameter 'systemProperties' is deprecated: Use systemPropertyVariables instead.
[INFO] Tests are skipped.
[INFO]
[INFO] --- spring-boot:3.3.4:process-aot (process-aot) @ service ---
Standard Commons Logging discovery in action with spring-jcl: please remove commons-logging.jar from classpath in order to avoid potential conflicts

. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/

:: Spring Boot :: (v3.3.4)

2024-10-21T18:17:33.941+03:00 INFO 18298 --- [ main] com.example.service.ServiceApplication : Starting ServiceApplication using Java 23 with PID 18298 (/Users/jlong/Desktop/gcp-webinar/service/target/classes started by jlong in /Users/jlong/Desktop/gcp-webinar/service)
2024-10-21T18:17:33.945+03:00 INFO 18298 --- [ main] com.example.service.ServiceApplication : No active profile set, falling back to 1 default profile: "default"
2024-10-21T18:17:34.264+03:00 INFO 18298 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Spanner repositories in DEFAULT mode.
2024-10-21T18:17:34.316+03:00 INFO 18298 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 49 ms. Found 1 Spanner repository interface.
2024-10-21T18:17:34.403+03:00 INFO 18298 --- [ main] faultConfiguringBeanFactoryPostProcessor : No bean named 'errorChannel' has been explicitly defined. Therefore, a default PublishSubscribeChannel will be created.
2024-10-21T18:17:34.406+03:00 INFO 18298 --- [ main] faultConfiguringBeanFactoryPostProcessor : No bean named 'integrationHeaderChannelRegistry' has been explicitly defined. Therefore, a default DefaultHeaderChannelRegistry will be created.
2024-10-21T18:17:34.846+03:00 INFO 18298 --- [ main] o.s.c.s.b.BinderChildContextInitializer : Beginning AOT processing for binder child contexts
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.730 s
[INFO] Finished at: 2024-10-21T18:17:36+03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.3.4:process-aot (process-aot) on project service: Unable to compile generated source
[ERROR] com.example.service.Dog is not public in com.example.service; cannot be accessed from outside package /Users/jlong/Desktop/gcp-webinar/service/target/spring-aot/main/sources/com/google/cloud/spring/data/spanner/repository/support/SpannerRepositoryFactoryBean__BeanDefinitions.java 3:27
[ERROR] com.example.service.DogRepository is not public in com.example.service; cannot be accessed from outside package /Users/jlong/Desktop/gcp-webinar/service/target/spring-aot/main/sources/com/google/cloud/spring/data/spanner/repository/support/SpannerRepositoryFactoryBean__BeanDefinitions.java 4:27
[ERROR] com.example.service.DogRepository is not public in com.example.service; cannot be accessed from outside package /Users/jlong/Desktop/gcp-webinar/service/target/spring-aot/main/sources/com/google/cloud/spring/data/spanner/repository/support/SpannerRepositoryFactoryBean__BeanDefinitions.java 34:106
[ERROR] com.example.service.Dog is not public in com.example.service; cannot be accessed from outside package /Users/jlong/Desktop/gcp-webinar/service/target/spring-aot/main/sources/com/google/cloud/spring/data/spanner/repository/support/SpannerRepositoryFactoryBean__BeanDefinitions.java 34:127

```

this doesn't occur for other spring data modules.

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure with the supplied pom.xml by running the Spring Boot process-aot goal, then inspect the generated target/spring-aot/main/sources/com/google/cloud/spring/data/spanner/repository/support/SpannerRepositoryFactoryBean__BeanDefinitions.java. Trace how the non-public com.example.service.Dog and DogRepository types are referenced and compare the behavior with other Spring Data modules. Done means native-image AOT processing succeeds without requiring those application types to be public.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring, spring-boot
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.