-
Spring boot has the ability to create executable jars, which it does by rewriting the first few bytes of the jar file At runtime, wire tries to load proto files from the classpath, treating the classpath as a zip file. In CoreLoader: override fun load(path: String): ProtoFile {
if (isWireRuntimeProto(path)) {
FileSystem.RESOURCES.read("/".toPath() / path) {
val data = readUtf8()
val location = Location.get(path)
val element = ProtoParser.parse(location, data)
return ProtoFile.get(element)
}
}
throw error("unexpected load: $path")
} This ultimately ends up in the following stack trace:
This code all works fine when running from IntelliJ, or in tests. It's not until runtime, within the booted jar that it becomes problematic. This snippet from the spring docs suggest that this should still be possible, but I'm not sure how to change things to make it work.
I'm fairly stuck / blocked by this. Does anyone have any suggestions on how to push this forward? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 7 replies
-
This probably needs an Okio issue filed. |
Beta Was this translation helpful? Give feedback.
-
I created an issue in Okio here square/okio#1094 |
Beta Was this translation helpful? Give feedback.
-
Thanks for creating the issue. I agree that's probably the right place. However, right now, I seem to be hitting brick walls with every workaround I try. Any advice here would be greatly apprecaited. Here's what I've tried: Inject a different implementationI couldn't find a way to wire in a different implementation of the CoreLoader, or of the FileSystem.RESOURCES. I noticed this comment in
However, I can't find a way to provide my own implementation that will prevent Turn off Spring Boot executable jars, and export the dependencies explicitlyTurns out that the Spring Boot plugin will allow you to make specific jars explicitly available in the fat jar. This kinda worked, but the CoreLoader is iterating over every jar in the classpath, and throws NullPointer exceptions when the file isn't available. (Again, this is more for the okio team, but listing it here for completeness). Try to implement my own SchemaLoader / CoreLoader implementationsSince my entry point is to a However, there's quite a few internal scoped classes involved (Like Monkey patching the reference to
|
Beta Was this translation helpful? Give feedback.
-
FWIW, I ended up working around this by removing spring boot's maven plugin, and using a classic Not ideal, but works. If anyone is interested in the final config, you can see it here |
Beta Was this translation helpful? Give feedback.
-
I have issues deploying the Vaadin app using appassembler ( I see that something related has been fixed in 4.3.0 But still receive exception when running app as spring jar with the wire lib inside private Schema loadFromFilesystem(List<String> locations) throws IOException {
SchemaLoader schemaLoader = new SchemaLoader(FileSystems.getDefault());
List<Location> wireLocations =
locations.stream().map(Location::get).collect(Collectors.toList());
schemaLoader.initRoots(wireLocations, List.of());
return schemaLoader.loadSchema(); // exception here
}
Is it something wrong with my code or |
Beta Was this translation helpful? Give feedback.
-
What it looks like is ResourceFileSystem is trying (and failing) to load a Some fixes to try:
|
Beta Was this translation helpful? Give feedback.
FWIW, I ended up working around this by removing spring boot's maven plugin, and using a classic
appassembler-maven-plugin
andmaven-assembly-plugin
instead.Not ideal, but works.
If anyone is interested in the final config, you can see it here