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

Runtime crash in spring 5.3/spring-native with JDK 17 #3870

Closed
phejl opened this issue Oct 6, 2021 · 11 comments · Fixed by #3979
Closed

Runtime crash in spring 5.3/spring-native with JDK 17 #3870

phejl opened this issue Oct 6, 2021 · 11 comments · Fixed by #3979
Assignees
Labels
bug native-image spring spring related issue

Comments

@phejl
Copy link

phejl commented Oct 6, 2021

Describe the issue
The generated image crashes at runtime when isSealed method of Class is invoked through reflection. Happens at https://github.com/spring-projects/spring-framework/blob/5.3.x/spring-aop/src/main/java/org/springframework/aop/framework/AopProxyUtils.java#L145

Describe GraalVM and your environment:

  • GraalVM CE 21.3.0-dev-20211001_0733
  • JDK 17
  • OS: Linux
  • Architecture: AMD64

More details

Caused by: com.oracle.svm.core.jdk.UnsupportedFeatureError: Unsupported method java.lang.Class.isSealed() is reachable: The declaring class of this element has been substituted, but this element is not present in the substitution class
	at com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:87)
	at java.lang.Class.isSealed(DynamicHub.java:4563)
	at java.lang.reflect.Method.invoke(Method.java:568)
	at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:282)
	at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:266)
	at org.springframework.aop.framework.AopProxyUtils.completeProxiedInterfaces(AopProxyUtils.java:145)
@oubidar-Abderrahim
Copy link
Member

Hi, thank you for reaching out about this issue, could you please provide us with a reproducer to use?

@sdeleuze
Copy link
Collaborator

sdeleuze commented Oct 18, 2021

I confirm this bug with our latest GraalVM 21.3 (likely final) build, you can reproduce it with security-method or batch samples.

Could you please tag this issue with spring label?

@phejl
Copy link
Author

phejl commented Oct 18, 2021

@sdeleuze FYI There is one more reported by me I suffered from when using spring-native: #3875

@oubidar-Abderrahim
Copy link
Member

@sdeleuze I cloned the repo and run build.sh in spring-native/samples/security-method All I can see is this message at the end: FAILURE: an error occurred when compiling the native image.
the same message is shown when using JDK17 and JDK11. not sure if there is any prerequisites that I am missing.
Would you mind clarifying the steps to actually see the error? Thank you

@sdeleuze
Copy link
Collaborator

Maybe try to run first ./build.sh at the root of Spring Native repo to install locally 0.11, then ./build.sh from samples/security-method. I just tried and it worked for me.

If still not on your side, please share the error message.

sdeleuze added a commit to spring-attic/spring-native that referenced this issue Oct 22, 2021
@sdeleuze
Copy link
Collaborator

Also please make sure to use your current local copy or checkout later spring-attic/spring-native@136b613 since I have just pushed a temporary workaround.

Fixing this issue is still very much needed since Spring will crash with sealed classes, my workaround just allow applications not used them to work.

@oubidar-Abderrahim
Copy link
Member

I run the build.sh in the root of Spring Native repo and the build was successful, but when I run build.sh inside security-method on my Ubuntu 18.04, I got:

=== Building security-method sample ===
Packaging security-method with Maven (native)
Unable to parse command line options: Unrecognized option: -ntp

usage: mvn [options] [<goal(s)>] [<phase(s)>]

Options:
 -am,--also-make                        If project list is specified, also
                                        build projects required by the
                                        list
 -amd,--also-make-dependents            If project list is specified, also
                                        build projects that depend on
                                        projects on the list
 -B,--batch-mode                        Run in non-interactive (batch)
                                        mode (disables output color)
 -b,--builder <arg>                     The id of the build strategy to
                                        use
 -C,--strict-checksums                  Fail the build if checksums don't
                                        match
 -c,--lax-checksums                     Warn if checksums don't match
 -cpu,--check-plugin-updates            Ineffective, only kept for
                                        backward compatibility
 -D,--define <arg>                      Define a system property
 -e,--errors                            Produce execution error messages
 -emp,--encrypt-master-password <arg>   Encrypt master security password
 -ep,--encrypt-password <arg>           Encrypt server password
 -f,--file <arg>                        Force the use of an alternate POM
                                        file (or directory with pom.xml)
 -fae,--fail-at-end                     Only fail the build afterwards;
                                        allow all non-impacted builds to
                                        continue
 -ff,--fail-fast                        Stop at first failure in
                                        reactorized builds
 -fn,--fail-never                       NEVER fail the build, regardless
                                        of project result
 -gs,--global-settings <arg>            Alternate path for the global
                                        settings file
 -gt,--global-toolchains <arg>          Alternate path for the global
                                        toolchains file
 -h,--help                              Display help information
 -l,--log-file <arg>                    Log file where all build output
                                        will go (disables output color)
 -llr,--legacy-local-repository         Use Maven 2 Legacy Local
                                        Repository behaviour, ie no use of
                                        _remote.repositories. Can also be
                                        activated by using
                                        -Dmaven.legacyLocalRepo=true
 -N,--non-recursive                     Do not recurse into sub-projects
 -npr,--no-plugin-registry              Ineffective, only kept for
                                        backward compatibility
 -npu,--no-plugin-updates               Ineffective, only kept for
                                        backward compatibility
 -nsu,--no-snapshot-updates             Suppress SNAPSHOT updates
 -o,--offline                           Work offline
 -P,--activate-profiles <arg>           Comma-delimited list of profiles
                                        to activate
 -pl,--projects <arg>                   Comma-delimited list of specified
                                        reactor projects to build instead
                                        of all projects. A project can be
                                        specified by [groupId]:artifactId
                                        or by its relative path
 -q,--quiet                             Quiet output - only show errors
 -rf,--resume-from <arg>                Resume reactor from specified
                                        project
 -s,--settings <arg>                    Alternate path for the user
                                        settings file
 -t,--toolchains <arg>                  Alternate path for the user
                                        toolchains file
 -T,--threads <arg>                     Thread count, for instance 2.0C
                                        where C is core multiplied
 -U,--update-snapshots                  Forces a check for missing
                                        releases and updated snapshots on
                                        remote repositories
 -up,--update-plugins                   Ineffective, only kept for
                                        backward compatibility
 -v,--version                           Display version information
 -V,--show-version                      Display version information
                                        WITHOUT stopping build
 -X,--debug                             Produce execution debug output
FAILURE: an error occurred when compiling the native image.

this happens with both jdk11 and jdk17. this is the output of mvn --version

Apache Maven 3.6.0
Maven home: /usr/share/maven
Java version: 17, vendor: GraalVM Community, runtime: /home/abderrahim/Downloads/graalvm-ce-java17-22.0.0-dev
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.4.0-84-generic", arch: "amd64", family: "unix"

@oubidar-Abderrahim
Copy link
Member

I am trying currently on macOS Catalina, but running the security-method's build.sh is hanging for over 20min now, the only output there is :

=== Building security-method sample ===
Packaging security-method with Maven (native)

this is the maven version in my mac:

~ mvn --version       
Apache Maven 3.6.2 (40f52333136460af0dc0d7232c0dc0bcf0d9e117; 2019-08-27T16:06:16+01:00)
Maven home: /usr/local/Cellar/maven/3.6.2/libexec
Java version: 11.0.13, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/graalvm-ee-java11-21.3.0/Contents/Home
Default locale: en_MA, platform encoding: UTF-8
OS name: "mac os x", version: "10.15.7", arch: "x86_64", family: "mac"

@oubidar-Abderrahim
Copy link
Member

Btw @sdeleuze , I would suggest having a branch without the workaround so that we can use it to test, this way you can keep the workaround on the main branch while we investigate on the other branch

@sdeleuze
Copy link
Collaborator

You are using an old and outdated version of Maven that does noes support -ntp, this option is supported as of Maven 3.6.1 released in 2019. No need for a branch just checkout 136b6131012252987f4372570bdc01c9db614958 revision.

@sdeleuze
Copy link
Collaborator

sdeleuze commented Oct 29, 2021

For the long time without outputs, I guess that's due to the verify.sh scripts timeout, you can comment the various checks or compile and run the app directly with mvn -Pnative clean package then target/security-method.

Do forget before compiling the app to run locally from the root of spring-native ./build.sh or mvn install in order to install locally Spring Native 0.11.0-SNAPSHOT that has this issue, not the one available on Maven repositories with the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug native-image spring spring related issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants