Open lwpk110 opened 5 years ago
Which version are you using? I think it's fixed by this https://github.com/dadoonet/elasticsearch-beyonder/pull/43.
v 5.0
That's why. It was fixed in 6.5 and 7.0 IIRC.
but i hacked this class to my project, it still can't work.
log below:
f.p.elasticsearch.tools.ResourceList : ==> jar prefix:[BOOT-INF/lib/xb-lbs-core-1.0.0-SNAPSHOT.jar/fr/pilato/elasticsearch/tools/ResourceList.class]
by the way, i package my app to a jar will occur the problem ,by command 'java -jar app.jar', when i use IDE to run will work ok.
What did you do exactly? Could you reproduce the problem with 7.0?
ok, i will try it, ty
Any news?
Can confirm, doesn't work in multi module projects. I fixed it by using the maven resources plugin and copying the index configs from the other module into the actual packaged module. Didn't look through the code too thorough, but it seems like it can't locate additional resources in the BOOT-INF/lib folders.
It would help if you could share a full simple (the easiest one as possible) which could show the problem. And if you have a fix what is it actually (in another commit).
Sorry, I just saw it. I think there may be some problems in obtaining path of source file. like that
String filepath;
if(ResourceUtils.isFileURL(resource.getURL())){ //File url
filepath= ((FileSystemResource) resource).getPath();
}else { //jar url @see {@link ResourceUtils#isJarUrl}
filepath = ((ClassPathResource) resource).getPath();
}
@lwpk110 where this code is coming from? Any idea on how to fix this issue? Does anyone could provide a simple sample project that shows the problem so I can may be work on a fix?
I've found the problem. In a multi module project, when the main module depends on another sub module, and the sub module is responsible for handling es.when the main module is packaged as jar, and the main module also needs to parse the sub module jar package when the app runs. i think we must improve this part,and let it support sub-jar resolving: {@link fr.pilato.elasticsearch.tools.ResourceList#getResources(String)}
if (dirURL.getProtocol().equals("jar")) {
/* A JAR path */
logger.trace("found a jar file resource: {}", dirURL);
String jarPath = dirURL.getPath().substring(5, dirURL.getPath().indexOf("!")); //strip out only the JAR file
JarFile jar = new JarFile(URLDecoder.decode(jarPath, "UTF-8"));
Enumeration<JarEntry> entries = jar.entries(); //gives ALL entries in jar
Set<String> result = new HashSet<>(); //avoid duplicates in case it is a subdirectory
while(entries.hasMoreElements()) {
String name = entries.nextElement().getName();
if (name.startsWith(root)) { //filter according to the path
String entry = name.substring(root.length());
int checkSubdir = entry.indexOf("/");
if (checkSubdir >= 0) {
// if it is a subdirectory, we just return the directory name
entry = entry.substring(0, checkSubdir);
}
result.add(entry);
}
}
Yeah. I guess so.
it would help a lot if someone could provide a sample project which reproduces the problem. That way I could work on a patch and make sure it solves it.
or better, if someone could provide the patch itself 😉
i integrate es with spring-elasticsearch,my project is multi module project. when use idea tool run app, it's ok,but when i package it to jar , it doesn't work. i debug it,found 'ResourceList' cause the problem. jar file can't read valid classpaht resource, it can't read the resource of sub moudule. expect fix it! for exam:
jar:file:/C:/Users/steven/Desktop/delivery/xb-lbs-service-1.0.0.jar!/BOOT-INF/lib/xb-lbs-core-1.0.0-SNAPSHOT.jar!/elasticsearch/client/rest/