Closed cgoel123 closed 7 years ago
Hi @cgoel123
You'll need to do something slightly different to get it to work in a fat jar. I've used the below code in the past to solve this issue. Let me know how you get on with it.
URI uri = cqlmigrateApp.class.getResource("/cql/").toURI();
if (uri.getScheme().equals("jar")) {
String[] parts = uri.toString().split("!");
String jar = parts[0];
String entry = parts[1];
try {
URI jarUri = URI.create(jar);
FileSystem fileSystem;
try {
fileSystem = FileSystems.getFileSystem(jarUri);
} catch (FileSystemNotFoundException e) {
fileSystem = FileSystems.newFileSystem(jarUri, emptyMap());
}
schemas = fileSystem.getPath(entry);
} catch (IOException e) {
throw new RuntimeException(e);
}
} else {
schemas = Paths.get(uri);
}
Thanks I will try this
Closing this, let me know if you are still having issues.
I am using below code line to execute my Java App which is simply using cqlmigrate as maven dependency. schemas = Paths.get(cqlmigrateApp.class.getResource("/cql/").toURI()); When I run the java program as a stand alone it works fine , keyspace gets created and .cql files run successfully. But when using same code I build a fat jar and run it. Then it seems the code is unable to obtain the /cql folder path from within the jar. And exception is thrown java.nio.file.FileSystemNotFoundException. The program stops here and the lock is held on schema and I can not do anything. Could anyone help here please ? Regards Chandan