I developed the Solr plugin and tested it using the Solr Test Framework . I am trying to upgrade my plugin from Solr 4.6 to Solr 4.10, replacing the old Solr 4.6 tanks with the new 4.10 jars that my plugin depends on. The update failed my tests with the following RuntimeException:
The resource was found in the class path, but could not be resolved to a normal file (perhaps it is part of the JAR file): solr / collection1
A resource solr/collection1is a directory located in the file system that contains, among other things, configuration files conf/solrconfig.xmland conf/schema.xmlnecessary for the test environment.
I looked at the source code of Solr, namely SolrTestCaseJ4.java , where an error occurred, and this file contains the following method getFile:
public static File getFile(String name) {
final URL url =
Thread.currentThread().getContextClassLoader().getResource(name);
try {
return new File(url.toURI());
} catch (Exception e) {
throw new RuntimeException("Resource was found on classpath, but cannot be resolved to a normal file (maybe it is part of a JAR file): " + name);
}
...
}
The method getFilereceives the string name="solr/collection1"as a parameter, and then it actually distorts it by setting the local variable in the URL urlfollowing invalid way:
jar: File: / C: /solr-4.10.3/solr-4.10.3/dist/solr-uima-4.10.3.jar/Solr/collection1
Then calling constructor Filec url.toURI()as a parameter ( new File(url.toURI())) causes an illegal argument to be thrown, indicating that the URI is not hierarchical. This is what throws the aforementioned Runtime exception.
getFile, URL url, Solr 4.6. Solr 4.6 getFile File name="solr/collection1":
File file = new File(name); //name = "solr/collection1"
Solr 4.6. Solr 4.10 URL? URL, , Runtime Exception?