cheerpj-meta
cheerpj-meta copied to clipboard
Error 404 when server serve a Java Spring Application
I experiment a bit CheerpJ to view a bit its ability. I tried to compile a demo Spring REST application to see the behaviour of the compiled code but the server doesn't find a file to serve (Error 404). Here is the server trace:
> python -m http.server 8080
Serving HTTP on :: port 8080 (http://[::]:8080/) ...
::ffff:127.0.0.1 - - [25/Jan/2022 12:29:31] "GET / HTTP/1.1" 200 -
::ffff:127.0.0.1 - - [25/Jan/2022 12:29:36] "GET /cheerp_test.html HTTP/1.1" 200 -
::ffff:127.0.0.1 - - [25/Jan/2022 12:29:39] "HEAD /backend.jar HTTP/1.1" 304 -
::ffff:127.0.0.1 - - [25/Jan/2022 12:29:39] "GET /backend.jar HTTP/1.1" 304 -
::ffff:127.0.0.1 - - [25/Jan/2022 12:29:40] "GET /backend.jar.js HTTP/1.1" 200 -
::ffff:127.0.0.1 - - [25/Jan/2022 12:29:45] code 404, message File not found
::ffff:127.0.0.1 - - [25/Jan/2022 12:29:45] "GET /BOOT-INF/classesfr/irisa/demobackend/DemoBackendApplication.js HTTP/1.1" 404 -
The path of the resource not found seems to be wrong, with a forgotten slash: "classes / fr" (I don't know if this is normal or not but I prefer to highlight it).
Steps I realize to compile my code:
> mvn package
> python cheerpj_2.2/cheerpjfy.py <resulting jar>.jar
Trace of the CheerpJ compilation step:
Compiling jar backend.jar
compiling org/springframework/boot/loader/ClassPathIndexFile.class ...
compiling org/springframework/boot/loader/ExecutableArchiveLauncher.class ...
compiling org/springframework/boot/loader/JarLauncher.class ...
compiling org/springframework/boot/loader/LaunchedURLClassLoader$DefinePackageCallType.class ...
compiling org/springframework/boot/loader/LaunchedURLClassLoader$UseFastConnectionExceptionsEnumeration.class ...
compiling org/springframework/boot/loader/LaunchedURLClassLoader.class ...
compiling org/springframework/boot/loader/Launcher.class ...
compiling org/springframework/boot/loader/MainMethodRunner.class ...
compiling org/springframework/boot/loader/PropertiesLauncher$1.class ...
compiling org/springframework/boot/loader/PropertiesLauncher$ArchiveEntryFilter.class ...
compiling org/springframework/boot/loader/PropertiesLauncher$ClassPathArchives.class ...
compiling org/springframework/boot/loader/PropertiesLauncher$PrefixMatchingArchiveFilter.class ...
compiling org/springframework/boot/loader/PropertiesLauncher.class ...
compiling org/springframework/boot/loader/WarLauncher.class ...
compiling org/springframework/boot/loader/archive/Archive$Entry.class ...
compiling org/springframework/boot/loader/archive/Archive$EntryFilter.class ...
compiling org/springframework/boot/loader/archive/Archive.class ...
compiling org/springframework/boot/loader/archive/ExplodedArchive$AbstractIterator.class ...
compiling org/springframework/boot/loader/archive/ExplodedArchive$ArchiveIterator.class ...
compiling org/springframework/boot/loader/archive/ExplodedArchive$EntryIterator.class ...
compiling org/springframework/boot/loader/archive/ExplodedArchive$FileEntry.class ...
compiling org/springframework/boot/loader/archive/ExplodedArchive$SimpleJarFileArchive.class ...
compiling org/springframework/boot/loader/archive/ExplodedArchive.class ...
compiling org/springframework/boot/loader/archive/JarFileArchive$AbstractIterator.class ...
compiling org/springframework/boot/loader/archive/JarFileArchive$EntryIterator.class ...
compiling org/springframework/boot/loader/archive/JarFileArchive$JarFileEntry.class ...
compiling org/springframework/boot/loader/archive/JarFileArchive$NestedArchiveIterator.class ...
compiling org/springframework/boot/loader/archive/JarFileArchive.class ...
compiling org/springframework/boot/loader/data/RandomAccessData.class ...
compiling org/springframework/boot/loader/data/RandomAccessDataFile$1.class ...
compiling org/springframework/boot/loader/data/RandomAccessDataFile$DataInputStream.class ...
compiling org/springframework/boot/loader/data/RandomAccessDataFile$FileAccess.class ...
compiling org/springframework/boot/loader/data/RandomAccessDataFile.class ...
compiling org/springframework/boot/loader/jar/AbstractJarFile$JarFileType.class ...
compiling org/springframework/boot/loader/jar/AbstractJarFile.class ...
compiling org/springframework/boot/loader/jar/AsciiBytes.class ...
compiling org/springframework/boot/loader/jar/Bytes.class ...
compiling org/springframework/boot/loader/jar/CentralDirectoryEndRecord$1.class ...
compiling org/springframework/boot/loader/jar/CentralDirectoryEndRecord$Zip64End.class ...
compiling org/springframework/boot/loader/jar/CentralDirectoryEndRecord$Zip64Locator.class ...
compiling org/springframework/boot/loader/jar/CentralDirectoryEndRecord.class ...
compiling org/springframework/boot/loader/jar/CentralDirectoryFileHeader.class ...
compiling org/springframework/boot/loader/jar/CentralDirectoryParser.class ...
compiling org/springframework/boot/loader/jar/CentralDirectoryVisitor.class ...
compiling org/springframework/boot/loader/jar/FileHeader.class ...
compiling org/springframework/boot/loader/jar/Handler.class ...
compiling org/springframework/boot/loader/jar/JarEntry.class ...
compiling org/springframework/boot/loader/jar/JarEntryCertification.class ...
compiling org/springframework/boot/loader/jar/JarFile$1.class ...
compiling org/springframework/boot/loader/jar/JarFile$JarEntryEnumeration.class ...
compiling org/springframework/boot/loader/jar/JarFile.class ...
compiling org/springframework/boot/loader/jar/JarFileEntries$1.class ...
compiling org/springframework/boot/loader/jar/JarFileEntries$EntryIterator.class ...
compiling org/springframework/boot/loader/jar/JarFileEntries$Offsets.class ...
compiling org/springframework/boot/loader/jar/JarFileEntries$Zip64Offsets.class ...
compiling org/springframework/boot/loader/jar/JarFileEntries$ZipOffsets.class ...
compiling org/springframework/boot/loader/jar/JarFileEntries.class ...
compiling org/springframework/boot/loader/jar/JarFileWrapper.class ...
compiling org/springframework/boot/loader/jar/JarURLConnection$1.class ...
compiling org/springframework/boot/loader/jar/JarURLConnection$JarEntryName.class ...
compiling org/springframework/boot/loader/jar/JarURLConnection.class ...
compiling org/springframework/boot/loader/jar/StringSequence.class ...
compiling org/springframework/boot/loader/jar/ZipInflaterInputStream.class ...
compiling org/springframework/boot/loader/jarmode/JarMode.class ...
compiling org/springframework/boot/loader/jarmode/JarModeLauncher.class ...
compiling org/springframework/boot/loader/jarmode/TestJarMode.class ...
compiling org/springframework/boot/loader/util/SystemPropertyUtils.class ...
compiling BOOT-INF/classes/fr/irisa/demobackend/Controller.class ...
Failure compiling BOOT-INF/classes/fr/irisa/demobackend/Controller.class
command: D:\IRISA\cheerpj\cheerpj_2.2\bin\cheerpj -llvm -llvm-exceptions -cp C:\Users\theog\AppData\Local\Temp\tmp4q65ecdh\rt.jar.dir\ BOOT-INF/classes/fr/irisa/demobackend/Controller.class
Using legacy codegen for BOOT-INF/classes/fr/irisa/demobackend/Controller.class
compiling BOOT-INF/classes/fr/irisa/demobackend/DemoBackendApplication.class ...
compiling BOOT-INF/classes/fr/irisa/demobackend/Input.class ...
compiling BOOT-INF/classes/fr/irisa/demobackend/Output.class ...
The compilation seems to fail with one of my classes, but succeed with the legacy.
Here is the code I try to compile (a minimal test code): https://github.com/theogiraudet/Minimal-Test-CheerpJ
Maybe CheerpJ cannot manage the particular structure of a Spring application, I prefer to make sure by asking you directly.
Thanks!
The 404 errors on .js are not critical. CheerpJ can compile classes on the fly.
The 304 error on the JAR itself is instead most likely a problem.
Please note that CheerpJ needs the original JARs as well, it cannot simply use the JAR.JS files.
I see thanks for your answer, however, the JAR seems to be at the right place and accessible:
What could be the problem?
I don't see any obvious problems. By our policies we cannot provide support for specific web-server issues for non-commercial users.
Does the TextDemo (used in our tutorial) work for you?
I understand. Yes, TextDemo works perfectly.
By the way, if this application is a web server, I can tell you already that it is not supported.
It could be possible to support internal connections (i.e. Java clients + Java server both running in CheerpJ) with some work. Although it's not currently on our plans we are always happy to prioritize feature requests from commercial users. If this sounds interesting please contact [email protected]