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 boot is not supported? #612

Open
kdaek21 opened this issue Nov 1, 2024 · 5 comments
Open

Spring boot is not supported? #612

kdaek21 opened this issue Nov 1, 2024 · 5 comments

Comments

@kdaek21
Copy link

kdaek21 commented Nov 1, 2024

When starting Spring Boot with IKVM, it dies with the following exception based on the net472 version.

Exception in thread "Thread-0" java.lang.IllegalStateException: java.lang.NullPointerException
at org.springframework.boot.loader.ExecutableArchiveLauncher.(ExecutableArchiveLauncher.java:57)
at org.springframework.boot.loader.WarLauncher.(WarLauncher.java:34)
at org.springframework.boot.loader.WarLauncher.main(WarLauncher.java:59)
Caused by: java.lang.NullPointerException
at org.springframework.boot.loader.jar.JarFile.getName(JarFile.java:415)
at IKVM.Java.Externs.java.util.zip.ClassStubZipEntry.expandIkvmClasses(ClassStubZipEntry.cs:197)
at java.util.zip.ClassStubZipEntry.expandIkvmClasses(Native Method)
at java.util.zip.ZipFile.(ZipFile.java:203)
at java.util.zip.ZipFile.(ZipFile.java:165)
at java.util.jar.JarFile.(JarFile.java:169)
at java.util.jar.JarFile.(JarFile.java:133)
at org.springframework.boot.loader.jar.AbstractJarFile.(AbstractJarFile.java:39)
at org.springframework.boot.loader.jar.JarFile.(JarFile.java:135)
at org.springframework.boot.loader.jar.JarFile.(JarFile.java:130)
at org.springframework.boot.loader.jar.JarFile.(JarFile.java:116)
at org.springframework.boot.loader.jar.JarFile.(JarFile.java:107)
at org.springframework.boot.loader.archive.JarFileArchive.(JarFileArchive.java:69)
at org.springframework.boot.loader.Launcher.createArchive(Launcher.java:163)
at org.springframework.boot.loader.ExecutableArchiveLauncher.(ExecutableArchiveLauncher.java:53)
... 2 more

@GeorgeS2019
Copy link

@kdaek21
Copy link
Author

kdaek21 commented Nov 5, 2024

The 'IKVM.Runtime.Launcher.Run (..' in the information of the provided link seems to be an error that occurs regardless of Spring Boot when running the compiled version with ikvmc.exe parameters set. (It seems to be an error that occurs because the version does not match based on the error content.)

The error content is slightly different due to the difference in the date of registration of the article in the provided link and the versions of IKVM. However, the error with 'IKVM.Runtime.Launcher.Run (..' seems to be an error that occurs regardless of Spring Boot.

  • As of the current time, the syntax for setting the parameters based on net472 is 'ikvmc -target:exe -r:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscorlib.dll" -r:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.dll" -runtime:"D:\Java\ikvm-jre8-net472\bin\IKVM.Runtime.dll" -main:Main Test.jar'.

If you create a project with 'dotnet new' and add IKVM, add jar with ikvmReference, build, and run it instead of directly setting the parameters, you will get the same error as in the first question. It seems that Spring Boot's jar is not a pure jar, but the Spring Boot team configures the contents of the jar or war according to their own structure and reads it with an internal dedicated loader (jar in jar and classes under a separate folder, and classes with business logic are in them, and the only part that matches the pure jar is the Spring Boot loader), so IKVM did not make it work according to this structure, so it is pure when converting statically or dynamically. It seems that the exception occurs because only the loader part of Spring Boot remains while the ones that do not fit the structure are removed. Can I assume that IKVM does not support structures like Spring Boot?

When running the build using ikvmRefererence, an exception occurs as below.


Unhandled exception: java.lang.IllegalStateException: java.lang.NullPointerException ---> java.lang.NullPointerException
--- End of inner exception stack trace ---
Location: org.springframework.boot.loader.ExecutableArchiveLauncher..ctor()
Location: org.springframework.boot.loader.JarLauncher..ctor()
Location: org.springframework.boot.loader.JarLauncher.main(String[] args)
Location: SpringBootTest.Main(String[] args) File C:\SpringTest3\Program.cs: line 5


  • In the first question, it is executed as java -jar SpringBoot.jar as in general Java, and it is displayed as WarLauncher, but ikvmReference does not recognize war, so I built it in jar format and converted it to CIL. Since it is executed, it appears as JarLauncher instead of WarLauncher.

@kdaek21
Copy link
Author

kdaek21 commented Nov 5, 2024

Additional test results show that if an exception containing 'IKVM.Runtime.Launcher.Run (..' occurs, it is because the [executable file name].config file is missing.
(If you convert directly using ikvmc.exe, only the assembly file is created and the remaining files required for execution are not created.)
It seems that the execution is stopped due to an exception caused by a version conflict of the 'System.Runtime.CompilerServices.Unsafe' assembly. When I took the config file from a working one, named it, and ran it, the pure jar conversion ran normally, but Spring Boot stopped with the following exception as I asked the first question.

Exception in thread "Thread-0" java.lang.IllegalStateException: java.lang.NullPointerException
at org.springframework.boot.loader.ExecutableArchiveLauncher.(ExecutableArchiveLauncher.java:52)
at org.springframework.boot.loader.JarLauncher.(JarLauncher.java:49)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)
Caused by: java.lang.NullPointerException
at org.springframework.boot.loader.jar.JarFile.getName(JarFile.java:399)
at IKVM.Java.Externs.java.util.zip.ClassStubZipEntry.expandIkvmClasses(Unknown Source)
at java.util.zip.ClassStubZipEntry.expandIkvmClasses(Native Method)
at java.util.zip.ZipFile.(ZipFile.java:203)
at java.util.zip.ZipFile.(ZipFile.java:165)
at java.util.jar.JarFile.(JarFile.java:169)
at java.util.jar.JarFile.(JarFile.java:133)
at org.springframework.boot.loader.jar.AbstractJarFile.(AbstractJarFile.java:39)
at org.springframework.boot.loader.jar.JarFile.(JarFile.java:130)
at org.springframework.boot.loader.jar.JarFile.(JarFile.java:125)
at org.springframework.boot.loader.jar.JarFile.(JarFile.java:111)
at org.springframework.boot.loader.jar.JarFile.(JarFile.java:102)
at org.springframework.boot.loader.archive.JarFileArchive.(JarFileArchive.java:69)
at org.springframework.boot.loader.Launcher.createArchive(Launcher.java:163)
at org.springframework.boot.loader.ExecutableArchiveLauncher.(ExecutableArchiveLauncher.java:48)
... 2 more

@kdaek21
Copy link
Author

kdaek21 commented Nov 6, 2024

https://github.com/orgs/ikvmnet/discussions/463

I thought the question in the post was asking how to solve the IKVM.Runtime.Launcher.Run error that appears when running Spring Boot, so I searched for various answers and hesitated to write an answer. I read it again now and it doesn't match my issue because it asks how to use the launcher (IKVM.Runtime.Launcher.Run) (I left the rough usage of the launcher and Spring Boot information I found as an additional answer to the question.)

What I registered as an issue was that when I ran it with the format java -jar SpringBoot.jar

Exception in thread "Thread-0" java.lang.IllegalStateException: java.lang.NullPointerException
at org.springframework.boot.loader.ExecutableArchiveLauncher.(ExecutableArchiveLauncher.java:52)
at org.springframework.boot.loader.JarLauncher.(JarLauncher.java:49)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)
Caused by: java.lang.NullPointerException
at org.springframework.boot.loader.jar.JarFile.getName(JarFile.java:399)

I registered it as a question to see if IKVM supports running SpringBoot because I got an error like this.

@wasabii
Copy link
Contributor

wasabii commented Nov 6, 2024

It should work, and whatever is causing it to not work should be fixed. So, in that sense, it's "supported". But I do not know what is actually wrong, and haven't had time to look at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants