Udayakumar opened SPR-16117 and commented
I am working on a drools project. The goal is to search all the rules(*.rdrl) files in the classpath and write it into the KieFileSystem. The rules file(.rdrl) will be present under multiple jar files. These jar files were added as a dependency in the drools project. Below is the code that is used to find all the .rdrl files.
ClassLoader classloader = this.getClass().getClassLoader(); ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver(classloader);
for (Resource file : resourcePatternResolver.getResources("classpath://.rdrl")) { System.out.println("name: " + file.getURL()); kieFileSystem.write(ResourceFactory.newUrlResource(file.getURL())); }
Below is the sample output printed by the above code
name: jar:file:/C:/mvn_repo/com/myteam/OOP_Modular/1.0.0/OOP_Modular-1.0.0.jar!/com/myteam/oop_modular/OOP_MOD_Network_In_Network.rdrl
name: jar:file:/C:/mvn_repo/com/myteam/OOP_Modular/1.0.0/OOP_Modular-1.0.0.jar!/com/myteam/oop_modular/OOP_MOD_Individual1.rdrl
name: jar:file:c:\mvn_repo\com\myteam\OOP_Modular\1.0.0\OOP_Modular-1.0.0.jar!/com/myteam/oop_modular/OOP_MOD_Network_In_Network.rdrl
name: jar:file:c:\mvn_repo\com\myteam\OOP_Modular\1.0.0\OOP_Modular-1.0.0.jar!/com/myteam/oop_modular/OOP_MOD_Individual1.rdrl
As seen from the above output there are two entries for the same files OOP_MOD_Network_In_Network.rdrl and OOP_MOD_Individual1.rdrl. When you look at the output, the path is exactly same except that one starts with /C: and other with c:
Because of this issue, since i am trying to write each rule twice into kiefilesystem, it throws an exception saying "Duplicate rule name".
Note: When using pattern such as ("classpath:com//.rdrl"), the resources are returned only once but we are not sure if the rules file will be present only under 'com', it can also be under 'org' or anything else.
System: Windows 7, JDK 1.8
Affects: 4.3.12, 5.0.1
Issue Links: - #20539 PathMatchingResourcePatternResolver provides duplicate resources when using classpath* prefix combined with ant-style - #18260 PathMatchingResourcePatternResolver does not consider manifest based classpaths
Referenced from: commits https://github.com/spring-projects/spring-framework/commit/8904de2149ef315e39d2464fa4283322d6137130, https://github.com/spring-projects/spring-framework/commit/a2f5e1254e3ccf190ec559492a33ca87c47e54d3
Backported to: 4.3.13
Comment From: spring-projects-issues
Juergen Hoeller commented
Looks like it's not the difference in slashes but the lower-case "c:" versus upper-case "C:" that's causing UrlResource.equals
to not match here... Let's see what we can do about it.
Comment From: spring-projects-issues
Juergen Hoeller commented
We're upper-casing drive letter prefixes in addClassPathManifestEntries
for proper duplicate detection now. Please give the upcoming 5.0.2.BUILD-SNAPSHOT
a try; I'll backport it to 4.3.13 if it works for you.
Comment From: spring-projects-issues
Udayakumar commented
Hello, Thanks for the prompt fix. i am stuck with downloading the artifactory. I tried by defining spring repo into the settings.xml however i got the following error,
Non-resolvable import POM: Could not transfer artifact org.springframework:spring-framework-bom:pom:5.0.2.BUILD-SNAPSHOT from/to repository.spring.snapshot (http://repo.spring.io/snapshot): connect timed out
Can you help.
Comment From: spring-projects-issues
Udayakumar commented
Found a strange thing. This issue do not exist in 4.2.5.RELEASE
Comment From: spring-projects-issues
Juergen Hoeller commented
The above looks like a temporary problem with the snapshot repository. Trying at a later point might work...
As for this not occurring with 4.2.5, this is expect since Spring's evaluation of the "java.class.path" manifest entry only came in 4.3: #18260
Comment From: spring-projects-issues
Udayakumar commented
I was able to download the artifact and install into local maven repo. I am finding it hard to test because we are using spring boot and versions are getting messed up. I am not able to use the downloaded artifact standalone.
Comment From: spring-projects-issues
Juergen Hoeller commented
Stéphane Nicoll, overriding the Spring Framework version underneath Boot to a snapshot should work under normal circumstances? Any advice?
Comment From: spring-projects-issues
Udayakumar commented
spring-framework-bom-5.0.2.BUILD-SNAPSHOT is missing
Comment From: spring-projects-issues
Juergen Hoeller commented
I've noticed that the last build hasn't properly completed, so would have received an outdated snapshot in any case. Maybe that's also the reason why the last published snapshot appears inconsistent. In any case, I've triggered a new build which should be ready and published in about half an hour.
Comment From: spring-projects-issues
Udayakumar commented
Hi Hoeller, Thanks for the support. Finally i was able to test with the snapshot. It seem to be working. Hope it works for all scenarios. Kindly let me know if it will be available in 4.3.12.RELEASE version. Please make it available as part of spring boot versions as well.
Comment From: spring-projects-issues
Juergen Hoeller commented
Good to hear, thanks for the feedback!
I'll backport this to 4.3.13 tomorrow, along with a few other refinements. Both 5.0.2 and 4.3.13 are scheduled for release on November 15th, with corresponding Boot 2.0 RC1 and Boot 1.5.9 releases following soon thereafter.