Native compilation with GraalVM
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 38/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- docker, java, spring-boot
- Domain
- api, build-system
Research direction
Start by reproducing the native Spring Boot image build and the Directory users.list().execute() call described in the issue, then compare the generated request URL with the JVM result. The payload names no repository files or tests; done means query parameters such as domain and maxResults are retained in the native build and the directory request succeeds.
Written by the indexing model from the issue text.
Description
There is an issue when using native compilation with GraalVM. I'm trying to use the Admin SDK API Client Library for directory operations.
Environment details
- Admin SDK API Client Library, version directory_v1-rev20240924-2.0.0
- Java Temurin 21
- Native compilation of a Spring Boot 3.3.4 app using by default at this time :
- paketo-buildpacks/ca-certificates 3.8.6
- paketo-buildpacks/bellsoft-liberica 10.9.0
- paketo-buildpacks/syft 2.1.0
- paketo-buildpacks/executable-jar 6.11.3
- paketo-buildpacks/spring-boot 5.31.2
- paketo-buildpacks/native-image 5.14.4
Steps to reproduce
Fresh Spring Boot 3.3.4 project.
Maven configuration
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-admin-directory</artifactId>
<version>directory_v1-rev20240924-2.0.0</version>
</dependency>
...
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
</plugin>
Build Directory service
private Directory buildDirectoryService(@Nonnull final String gcpKey, @Nonnull final String serviceAccountUser) throws IOException, GeneralSecurityException {
final ServiceAccountCredentials sourceCredentials =
ServiceAccountCredentials.fromStream(...)
.toBuilder()
.setServiceAccountUser(serviceAccountUser)
.setScopes(ImmutableSet.of(
DirectoryScopes.ADMIN_DIRECTORY_GROUP_READONLY,
DirectoryScopes.ADMIN_DIRECTORY_USER_READONLY
))
.build();
return new Directory.Builder(Utils.getDefaultTransport(), Utils.getDefaultJsonFactory(), new HttpCredentialsAdapter(sourceCredentials))
.setApplicationName("MY_APP")
.build();
}
Add reflection hints for ErrorInfo.class
@Configuration
@ImportRuntimeHints(NativeImageHints.class)
class NativeImageHints implements RuntimeHintsRegistrar {
@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
hints.reflection().registerType(ErrorInfo.class, (type) -> type.withConstructor(Collections.emptyList(), ExecutableMode.INVOKE));
}
}
Directory api call
final Users batch = directory
.users()
.list()
.setMaxResults(100)
.setDomain("my-domain.com")
.execute();
Build and run image
mvn clean spring-boot:build-image -e --no-transfer-progress -P native -D skipTests=true
docker run -p 8080:8080 my-app:0.0.1-SNAPSHOT
Result of directory execute()
2024-10-14T12:44:13.891Z INFO 1 --- [my-app] [nio-8080-exec-1] c.google.api.client.http.HttpTransport : {
"error": {
"code": 400,
"message": "Bad Request",
"errors": [
{
"message": "Bad Request",
"domain": "global",
"reason": "badRequest"
}
]
}
}
Reason
If I launch the app in DEBUG logging mode, I can see that the URL for the API query is not properly prepared :
curl -v --compressed
-H 'Accept-Encoding: gzip'
-H 'Authorization: <Not Logged>'
-H 'User-Agent: MY_APP Google-API-Java-Client/2.7.0 Google-HTTP-Java-Client/1.45.0 (gzip)'
-H 'x-goog-api-client: gl-java/21.0.4-graalvm gdcl/2.7.0 linux/6.8.0' -- 'https://admin.googleapis.com/admin/directory/v1/users'
instead of
curl -v --compressed
-H 'Accept-Encoding: gzip'
-H 'Authorization: <Not Logged>'
-H 'User-Agent: MY_APP Google-API-Java-Client/2.7.0 Google-HTTP-Java-Client/1.45.0 (gzip)'
-H 'x-goog-api-client: gl-java/21.0.4-graalvm gdcl/2.7.0 linux/6.8.0' -- 'https://admin.googleapis.com/admin/directory/v1/users?domain=my-domain.com&maxResults=100'
- Dominant language
- Java
- Stars
- 725
- Forks
- 394
- Avg merge
- 42m
- Merged PRs (30d)
- 257
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from googleapis/google-api-java-client-services
-
priority: p3 type: docs
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
priority: p3 type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 50/100
googleapis/google-api-java-client-services#29581 · 2 comments ·
-
priority: p3 type: feature request
Difficulty 4/5 3-5 days Newbie friendliness 38/100
googleapis/google-api-java-client-services#29317 · 1 comment ·
-
priority: p3 type: bug
Difficulty 5/5 Over a week Newbie friendliness 35/100
googleapis/google-api-java-client-services#26505 · 7 comments · 1 reaction ·
-
priority: p3 type: bug
Difficulty 3/5 1-2 days Newbie friendliness 35/100
All issues in googleapis/google-api-java-client-services
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
checkstyle/test-configs#263 ·
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 90/100
apache/cloudstack#14222 ·
-
[BUG]茶杯方块在取茶时会引发崩溃 Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
1.0.0-alpha2 Type/Improvement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
wso2/dpdp-accelerator#272 ·