I am building a project that relies on several Spring libraries. I applied the shadow plugin (https://github.com/johnrengelman/shadow) and ran the runShadow task and get the following error:
Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/context]
After doing some research, I think the problem is that each of the Spring library contains a spring.handlers and spring.schemas files under a META-INF directory, so they are overriding each other. There is the maven shade plugin which takes care of this problem for maven, so I assume that Shadow which is roughly the equivalent of Mavenâs Shade plugin can also merge all the separate spring.handlers and spring.schemas files into just one that includes all of the configurations. I just donât know what is the syntax to use â there is only a snippet about a Transformers api in the github README for Shadow. Has anyone run into this issue with Gradle before? If so, how did you solve it?
I first tried adding that snippet of code to the build file as shown below and ran the shadowJar task but I got the following error:
Could not find method mergeServiceFiles() for arguments [META-INF, build_uikua424h66rqmcd6pekgkm62$_run_closure1_closure3@28341220] on project ':EmailConsumer'
I then tried variations of the syntax. The first was:
shadowJar {
mergeServiceFiles('META-INF')
include 'spring.*'
}
after which I ran shadowJar followed by runShadow:
Error: Could not find or load main class com.se.email.submexch.consum.PollingConsumer
which is rather odd. Perhaps the Manifest file got merged as well?
and ran shadowJar followed by runShadow, but that just gives me the same âcould not find namespace handlerâ that I mentioned in my original post. Any ideas?
That also gave me the âunable to find namespace handlerâ error. Thank you very much for your help â but I think I will go the route of manually merging the files for now.