Unable to extend URL protocols handled by ClasspathIterable #360

lmcgrath opened this Issue Jul 16, 2012 · 0 comments


None yet
2 participants

I'm working to integrate Cucumber with the Arquillian test framework, and I found a major problem with the ClasspathResourceLoader: there is no way to extend the capabilities of the resource loader to be able to conditionally load resources based on the protocol of each resource's URL. If there's a funky URL protocol that doesn't refer to a filesystem resource or a JAR file, the ClasspathResourceLoader will fail to load the resource.

I ran into this problem while executing Cucumber tests with Arquillian and JBoss AS 7.1.1.Final. When the Cucumber tests are running within JBoss AS, each resource URL returned by ClassLoader.getResources() uses the "vfs" protocol to indicate handling by the JBoss Virtual File System.

Here's the problem:

  • ClasspathResourceLoader creates ClasspathIterable.
  • ClasspathIterable creates ZipResourceIterator for any resource URL's with "jar" protocol or FileResourceIterator for all other protocols.
  • FileResourceIterator receives invalid path to resource that doesn't exist because JBoss VFS abstracts away the physical location of all resources.
  • I get IllegalArgumentException: "Not a file or directory: C:\jboss-as\install\dir\bin\content\weirdo-location-that-doesn't-really-exist-unless-you-load-me-using-vfs".

Currently, there is no way to extend or modify the resource loading behavior of the ClasspathResourceLoader class. I'm looking at having to completely reimplement the ResourceLoader interface and manually providing Backend implementations to the Runtime because of the hard dependency on the ClasspathResourceLoader class in Runtime.loadBackends(). Most of the classes used by the ClasspathResourceLoader are also package-private, so existing code cannot be reused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment