Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
joshlong opened this issue Oct 21, 2024 · 0 comments
Labels
priority: p2 type: bug Something isn't working

Comments

@joshlong
Copy link

joshlong commented Oct 21, 2024

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:


<?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>3.3.4</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>
	<groupId>com.example</groupId>
	<artifactId>service</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>service</name>
	<description>Demo project for Spring Boot</description>
	<url/>
	<licenses>
		<license/>
	</licenses>
	<developers>
		<developer/>
	</developers>
	<scm>
		<connection/>
		<developerConnection/>
		<tag/>
		<url/>
	</scm>
	<properties>
		<java.version>21</java.version>
		<spring-ai.version>1.0.0-M3</spring-ai.version>
		<spring-cloud-gcp.version>5.7.0</spring-cloud-gcp.version>
		<spring-cloud.version>2023.0.3</spring-cloud.version>
	</properties>
	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
		<dependency>
			<groupId>com.google.cloud</groupId>
			<artifactId>spring-cloud-gcp-starter</artifactId>
		</dependency>
		<dependency>
			<groupId>com.google.cloud</groupId>
			<artifactId>spring-cloud-gcp-starter-pubsub</artifactId>
		</dependency>
		<dependency>
			<groupId>com.google.cloud</groupId>
			<artifactId>spring-cloud-gcp-starter-storage</artifactId>
		</dependency>
	<!--	<dependency>
			<groupId>org.springframework.ai</groupId>
			<artifactId>spring-ai-pgvector-store-spring-boot-starter</artifactId>
		</dependency>-->
		<dependency>
			<groupId>org.springframework.ai</groupId>
			<artifactId>spring-ai-vertex-ai-gemini-spring-boot-starter</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-stream</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
		
		<dependency>
			<groupId>com.google.cloud</groupId>
			<artifactId>spring-cloud-gcp-starter-data-spanner</artifactId>
		</dependency>
		
		
<!--		-->


		<!--   -->
	 
		<!--        <dependency>
                    <groupId>org.springframework.ai</groupId>
                    <artifactId>spring-ai-pgvector-store-spring-boot-starter</artifactId>
                </dependency>-->
		<dependency>
			<groupId>com.google.cloud</groupId>
			<artifactId>spring-cloud-gcp-vision</artifactId>
		</dependency>
		
		
	</dependencies>
	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>org.springframework.cloud</groupId>
				<artifactId>spring-cloud-dependencies</artifactId>
				<version>${spring-cloud.version}</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
			<dependency>
				<groupId>org.springframework.ai</groupId>
				<artifactId>spring-ai-bom</artifactId>
				<version>${spring-ai.version}</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
			<dependency>
				<groupId>com.google.cloud</groupId>
				<artifactId>spring-cloud-gcp-dependencies</artifactId>
				<version>${spring-cloud-gcp.version}</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
		</dependencies>
	</dependencyManagement>

	<build>
		<plugins>
			<plugin>
				<groupId>org.graalvm.buildtools</groupId>
				<artifactId>native-maven-plugin</artifactId>
			</plugin>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>
	<repositories>
		<repository>
			<id>spring-milestones</id>
			<name>Spring Milestones</name>
			<url>https://repo.spring.io/milestone</url>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
		</repository>
	</repositories>

</project>

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.

@lqiu96 lqiu96 added type: bug Something isn't working priority: p2 labels Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants