-
Notifications
You must be signed in to change notification settings - Fork 41.4k
Closed
Description
Hi I'm using the Stormpath Java SDK as dependency in my spring-boot project and building the entire thing as a fat jar using the spring-boot gradle plugin, and it throws an exception trying get its manifest file.
java.lang.RuntimeException: Unable to obtain version from manifest path [jar:file:/Users/jarias/Code/jarias/tk/build/libs/tk-0.1.0.jar!/lib/stormpath-sdk-impl-0.8.1.jar!/META-INF/MANIFEST.MF]
at com.stormpath.sdk.impl.http.support.Version.getManifest(Version.java:56)
at com.stormpath.sdk.impl.http.support.Version.lookupClientVersion(Version.java:43)
at com.stormpath.sdk.impl.http.support.Version.<clinit>(Version.java:28)
at com.stormpath.sdk.impl.ds.DefaultDataStore.applyDefaultRequestHeaders(DefaultDataStore.java:593)
The code from Version.java looks like this:
private static String lookupClientVersion() {
Class clazz = Version.class;
String className = clazz.getSimpleName() + ".class";
String classPath = clazz.getResource(className).toString();
if (!classPath.startsWith("jar")) {
// Class not from JAR
return "NOT-FROM-JAR";
}
String manifestPath = classPath.substring(0, classPath.lastIndexOf("!") + 1) + "/META-INF/MANIFEST.MF";
Manifest manifest = getManifest(manifestPath);
Attributes attr = manifest.getMainAttributes();
String value = attr.getValue("Implementation-Version");
if (value == null) {
throw new IllegalStateException("Unable to obtain 'Implementation-Version' property from manifest.");
}
return value;
}
private static Manifest getManifest(String path) {
try {
return new Manifest(new URL(path).openStream());
} catch (IOException e) {
throw new RuntimeException("Unable to obtain version from manifest path [" + path + "]");
}
}
Is this something that can be done using the fat jar? What should code look like? And can it maintain compatibility when this lib is use in a non spring-boot fat jar?
If a fix is possible I'll pass it along to the Stormpath team.
By the way I got a similar issue with JBoss TS but it wasn't getting the manifest but a properties file thats inside the JBoss TS jar(s) my workaround in that case was to dup the prop file in my project.
Metadata
Metadata
Assignees
Labels
No labels