te')); return $arr; } /* 遍历用户所有主题 * @param $uid 用户ID * @param int $page 页数 * @param int $pagesize 每页记录条数 * @param bool $desc 排序方式 TRUE降序 FALSE升序 * @param string $key 返回的数组用那一列的值作为 key * @param array $col 查询哪些列 */ function thread_tid_find_by_uid($uid, $page = 1, $pagesize = 1000, $desc = TRUE, $key = 'tid', $col = array()) { if (empty($uid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('uid' => $uid), array('tid' => $orderby), $page, $pagesize, $key, $col); return $arr; } // 遍历栏目下tid 支持数组 $fid = array(1,2,3) function thread_tid_find_by_fid($fid, $page = 1, $pagesize = 1000, $desc = TRUE) { if (empty($fid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('fid' => $fid), array('tid' => $orderby), $page, $pagesize, 'tid', array('tid', 'verify_date')); return $arr; } function thread_tid_delete($tid) { if (empty($tid)) return FALSE; $r = thread_tid__delete(array('tid' => $tid)); return $r; } function thread_tid_count() { $n = thread_tid__count(); return $n; } // 统计用户主题数 大数量下严谨使用非主键统计 function thread_uid_count($uid) { $n = thread_tid__count(array('uid' => $uid)); return $n; } // 统计栏目主题数 大数量下严谨使用非主键统计 function thread_fid_count($fid) { $n = thread_tid__count(array('fid' => $fid)); return $n; } ?>maven - GraalVM native compilation of Spring Boot 3.4.2 fails with VMError$HostedError - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

maven - GraalVM native compilation of Spring Boot 3.4.2 fails with VMError$HostedError - Stack Overflow

programmeradmin5浏览0评论

Very basic app following the instructions at .html

No weird and wonderful dependencies or anything UPDATE pom.xml included

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns=".0.0" xmlns:xsi=";
         xsi:schemaLocation=".0.0 .0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.4.2</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.test</groupId>
    <artifactId>nativetest</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>native</name>
    <description>native</description>
    <url/>
    <licenses>
        <license/>
    </licenses>
    <developers>
        <developer/>
    </developers>
    <scm>
        <connection/>
        <developerConnection/>
        <tag/>
        <url/>
    </scm>
    <properties>
        <java.version>17</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>.graalvm.buildtools</groupId>
                <artifactId>native-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

mvn native:compile fails with Fatal error: com.oracle.svm.core.util.VMError$HostedError: com.oracle.svm.core.util.VMError$HostedError: New Method or Constructor found as reachable after static analysis: public .springframework.boot.ssl.SslBundle .springframework.boot.http.client.ClientHttpRequestFactorySettings.sslBundle()

$ java --version
openjdk 17.0.5 2022-10-18 LTS
OpenJDK Runtime Environment GraalVM 22.3.0 (build 17.0.5+8-LTS)
OpenJDK 64-Bit Server VM GraalVM 22.3.0 (build 17.0.5+8-LTS, mixed mode, sharing)

Do I need to do something different/not mentioned in the spring tutorial to get the native compilation to work?

Perhaps some mvn or pom changes required?

Can anyone assist with some steps to get the below command to succeed, please?

Is there perhaps a different spring-boot version that works better with graalvm native build? UPDATE: spring-boot-starter-parent version 3.3.8 build succeeds, so issue seems to only affect 3.4.2

$ ./mvnw -Pnative -DskipTests clean native:compile
...
...
...
[1/7] Initializing...                                                                                    (2.3s @ 0.25GB)
 Version info: 'GraalVM 22.3.0 Java 17 CE'
 Java version info: '17.0.5+8-LTS'
 C compiler: gcc (linux, x86_64, 13.3.0)
 Garbage collector: Serial GC
 1 user-specific feature(s)
 - .springframework.aot.nativex.feature.PreComputeFieldFeature
SLF4J(W): No SLF4J providers were found.
SLF4J(W): Defaulting to no-operation (NOP) logger implementation
SLF4J(W): See .html#noProviders for further details.
[2/7] Performing analysis...  [********]                                                                (13.3s @ 3.34GB)
  16,725 (92.41%) of 18,098 classes reachable
  27,019 (67.57%) of 39,988 fields reachable
  79,131 (62.19%) of 127,242 methods reachable
   1,021 classes,   353 fields, and 5,776 methods registered for reflection
      64 classes,    70 fields, and    55 methods registered for JNI access
       4 native libraries: dl, pthread, rt, z
[3/7] Building universe...                                                                               (2.2s @ 2.44GB)
[4/7] Parsing methods...      [*]                                                                        (1.4s @ 3.62GB)
[5/7] Inlining methods...     [****]                                                                     (0.9s @ 2.30GB)
[6/7] Compiling methods...    [***]                                                                      (9.4s @ 4.24GB)
[7/7] Creating image...
                                                                                  (0.0s @ 2.08GB)
Fatal error: com.oracle.svm.core.util.VMError$HostedError: com.oracle.svm.core.util.VMError$HostedError: New Method or Constructor found as reachable after static analysis: public .springframework.boot.ssl.SslBundle .springframework.boot.http.client.ClientHttpRequestFactorySettings.sslBundle()
    at .graalvm.nativeimage.builder/com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:72)
    at .graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:696)
    at .graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:535)
    at .graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:403)
    at .graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:580)
    at .graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:128)
Caused by: com.oracle.svm.core.util.VMError$HostedError: New Method or Constructor found as reachable after static analysis: public .springframework.boot.ssl.SslBundle .springframework.boot.http.client.ClientHttpRequestFactorySettings.sslBundle()
    at .graalvm.nativeimage.builder/com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:68)
    at .graalvm.nativeimage.builder/com.oracle.svm.hosted.reflect.ReflectionFeature.getOrCreateAccessor(ReflectionFeature.java:121)
    at .graalvm.nativeimage.builder/com.oracle.svm.core.reflect.target.ExecutableAccessorComputer.transform(ExecutableAccessorComputer.java:43)
    at .graalvm.nativeimage.builder/com.oracle.svm.hosted.substitute.ComputedValueFieldputeValue(ComputedValueField.java:343)
    at .graalvm.nativeimage.builder/com.oracle.svm.hosted.substitute.ComputedValueField.readValue(ComputedValueField.java:313)
    at .graalvm.nativeimage.builder/com.oracle.svm.core.meta.ReadableJavaField.readFieldValue(ReadableJavaField.java:38)
    at .graalvm.nativeimage.builder/com.oracle.svm.hosted.ameta.AnalysisConstantReflectionProvider.readValue(AnalysisConstantReflectionProvider.java:97)
    at .graalvm.nativeimage.builder/com.oracle.svm.hosted.meta.HostedField.readValue(HostedField.java:161)
    at .graalvm.nativeimage.builder/com.oracle.svm.hosted.image.NativeImageHeap.addObjectToImageHeap(NativeImageHeap.java:439)
    at .graalvm.nativeimage.builder/com.oracle.svm.hosted.image.NativeImageHeap.addObject(NativeImageHeap.java:295)
    at .graalvm.nativeimage.builder/com.oracle.svm.hosted.image.NativeImageHeap.processAddObjectWorklist(NativeImageHeap.java:598)
    at .graalvm.nativeimage.builder/com.oracle.svm.hosted.image.NativeImageHeap.addTrailingObjects(NativeImageHeap.java:198)
    at .graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:678)
    ... 4 more
------------------------------------------------------------------------------------------------------------------------
                        1.7s (5.0% of total time) in 41 GCs | Peak RSS: 6.73GB | CPU load: 16.70
========================================================================================================================

Very basic app following the instructions at https://docs.spring.io/spring-boot/how-to/native-image/developing-your-first-application.html

No weird and wonderful dependencies or anything UPDATE pom.xml included

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache./POM/4.0.0" xmlns:xsi="http://www.w3./2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache./POM/4.0.0 https://maven.apache./xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.4.2</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.test</groupId>
    <artifactId>nativetest</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>native</name>
    <description>native</description>
    <url/>
    <licenses>
        <license/>
    </licenses>
    <developers>
        <developer/>
    </developers>
    <scm>
        <connection/>
        <developerConnection/>
        <tag/>
        <url/>
    </scm>
    <properties>
        <java.version>17</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>.graalvm.buildtools</groupId>
                <artifactId>native-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

mvn native:compile fails with Fatal error: com.oracle.svm.core.util.VMError$HostedError: com.oracle.svm.core.util.VMError$HostedError: New Method or Constructor found as reachable after static analysis: public .springframework.boot.ssl.SslBundle .springframework.boot.http.client.ClientHttpRequestFactorySettings.sslBundle()

$ java --version
openjdk 17.0.5 2022-10-18 LTS
OpenJDK Runtime Environment GraalVM 22.3.0 (build 17.0.5+8-LTS)
OpenJDK 64-Bit Server VM GraalVM 22.3.0 (build 17.0.5+8-LTS, mixed mode, sharing)

Do I need to do something different/not mentioned in the spring tutorial to get the native compilation to work?

Perhaps some mvn or pom changes required?

Can anyone assist with some steps to get the below command to succeed, please?

Is there perhaps a different spring-boot version that works better with graalvm native build? UPDATE: spring-boot-starter-parent version 3.3.8 build succeeds, so issue seems to only affect 3.4.2

$ ./mvnw -Pnative -DskipTests clean native:compile
...
...
...
[1/7] Initializing...                                                                                    (2.3s @ 0.25GB)
 Version info: 'GraalVM 22.3.0 Java 17 CE'
 Java version info: '17.0.5+8-LTS'
 C compiler: gcc (linux, x86_64, 13.3.0)
 Garbage collector: Serial GC
 1 user-specific feature(s)
 - .springframework.aot.nativex.feature.PreComputeFieldFeature
SLF4J(W): No SLF4J providers were found.
SLF4J(W): Defaulting to no-operation (NOP) logger implementation
SLF4J(W): See https://www.slf4j./codes.html#noProviders for further details.
[2/7] Performing analysis...  [********]                                                                (13.3s @ 3.34GB)
  16,725 (92.41%) of 18,098 classes reachable
  27,019 (67.57%) of 39,988 fields reachable
  79,131 (62.19%) of 127,242 methods reachable
   1,021 classes,   353 fields, and 5,776 methods registered for reflection
      64 classes,    70 fields, and    55 methods registered for JNI access
       4 native libraries: dl, pthread, rt, z
[3/7] Building universe...                                                                               (2.2s @ 2.44GB)
[4/7] Parsing methods...      [*]                                                                        (1.4s @ 3.62GB)
[5/7] Inlining methods...     [****]                                                                     (0.9s @ 2.30GB)
[6/7] Compiling methods...    [***]                                                                      (9.4s @ 4.24GB)
[7/7] Creating image...
                                                                                  (0.0s @ 2.08GB)
Fatal error: com.oracle.svm.core.util.VMError$HostedError: com.oracle.svm.core.util.VMError$HostedError: New Method or Constructor found as reachable after static analysis: public .springframework.boot.ssl.SslBundle .springframework.boot.http.client.ClientHttpRequestFactorySettings.sslBundle()
    at .graalvm.nativeimage.builder/com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:72)
    at .graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:696)
    at .graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:535)
    at .graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:403)
    at .graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:580)
    at .graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:128)
Caused by: com.oracle.svm.core.util.VMError$HostedError: New Method or Constructor found as reachable after static analysis: public .springframework.boot.ssl.SslBundle .springframework.boot.http.client.ClientHttpRequestFactorySettings.sslBundle()
    at .graalvm.nativeimage.builder/com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:68)
    at .graalvm.nativeimage.builder/com.oracle.svm.hosted.reflect.ReflectionFeature.getOrCreateAccessor(ReflectionFeature.java:121)
    at .graalvm.nativeimage.builder/com.oracle.svm.core.reflect.target.ExecutableAccessorComputer.transform(ExecutableAccessorComputer.java:43)
    at .graalvm.nativeimage.builder/com.oracle.svm.hosted.substitute.ComputedValueFieldputeValue(ComputedValueField.java:343)
    at .graalvm.nativeimage.builder/com.oracle.svm.hosted.substitute.ComputedValueField.readValue(ComputedValueField.java:313)
    at .graalvm.nativeimage.builder/com.oracle.svm.core.meta.ReadableJavaField.readFieldValue(ReadableJavaField.java:38)
    at .graalvm.nativeimage.builder/com.oracle.svm.hosted.ameta.AnalysisConstantReflectionProvider.readValue(AnalysisConstantReflectionProvider.java:97)
    at .graalvm.nativeimage.builder/com.oracle.svm.hosted.meta.HostedField.readValue(HostedField.java:161)
    at .graalvm.nativeimage.builder/com.oracle.svm.hosted.image.NativeImageHeap.addObjectToImageHeap(NativeImageHeap.java:439)
    at .graalvm.nativeimage.builder/com.oracle.svm.hosted.image.NativeImageHeap.addObject(NativeImageHeap.java:295)
    at .graalvm.nativeimage.builder/com.oracle.svm.hosted.image.NativeImageHeap.processAddObjectWorklist(NativeImageHeap.java:598)
    at .graalvm.nativeimage.builder/com.oracle.svm.hosted.image.NativeImageHeap.addTrailingObjects(NativeImageHeap.java:198)
    at .graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:678)
    ... 4 more
------------------------------------------------------------------------------------------------------------------------
                        1.7s (5.0% of total time) in 41 GCs | Peak RSS: 6.73GB | CPU load: 16.70
========================================================================================================================
Share Improve this question edited yesterday capitalgsw asked 2 days ago capitalgswcapitalgsw 192 bronze badges New contributor capitalgsw is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct. 8
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Bot Commented 2 days ago
  • Clarified ask via edit – capitalgsw Commented yesterday
  • It is supposed to work with 3.4.2 - which dependencies are you using? – dan1st Commented yesterday
  • @dan1st have updated question with pom extract – capitalgsw Commented yesterday
  • I couldn't get the GraalVM distribution for Java v17 because of the license agreement and the requirement for an Oracle account. However, I was able to download v21 (graalvm-jdk-21.0.6+8.1, which is also an LTS version) and the demo project with the POM file you provided. It builds successfully with the command you referenced. Can you check that your local environment versions are supported? ref: docs.spring.io/spring-boot/system-requirements.html – Dmitriy Commented yesterday
 |  Show 3 more comments

1 Answer 1

Reset to default -1
$ java --version
openjdk 17.0.14 2025-01-21 LTS
OpenJDK Runtime Environment Liberica-NIK-23.0.7-1 (build 17.0.14+10-LTS)
OpenJDK 64-Bit Server VM Liberica-NIK-23.0.7-1 (build 17.0.14+10-LTS, mixed mode, sharing)

Using version 23.0.7.r17-nik VM solves this. So tutorial is slightly wrong (it says to use 22.3.r17-nik)

Thanks to @Dmitriy for the assist

发布评论

评论列表(0)

  1. 暂无评论