3 Replies Latest reply on Feb 18, 2008 3:25 PM by Adrian Brock

    Maven and url stream handlers

    Adrian Brock Master

      Related to this thread

      If you checkout the latest MC project and try to run the classloader-vfs
      tests it tells you can't create VFS files. This is because it doesn't recognise
      the vfsfile: protocol (even though it has been added to the system properties).

      This issue is specific to Maven, the tests work fine in the Eclipse.

      I tried to debug this before, but I couldn't work out the cause,
      because if I added a modified version of the URL class (with extra debugging)
      to the bootstrap classpath I couldn't reproduce the problem.

      The class from Sun's src.jar doesn't match what's in the JDK. ;-(

      I ended up hacking the test using reflection and setAccesible(true)
      to set the vfs url handler manually on the URL object.
      But I don't want to do that here, the construction of the VFS files
      are not in a test in this case, they are in real code.

      I'm guessing this has something to do with the way Maven is playing
      with the classloaders?

        • 1. Re: Maven and url stream handlers
          Paul Gier Master

          Yes, it might be related to how the surefire plugin forks the tests. You can pass classpath elements to the forked tests, but they aren't passed directly to the jvm. A basic jvm is created, and then a new classloader is created to load whatever things you need for the test.

          Maybe I'm wrong, but this sounds similar to a problem that Stale was having with some aop tests, when trying to use the javaagent option. But the problem was that there isn't a way to pass the necessary classpath to the jvm.

          I will take a look this week and see if I can fix this and get a patch submitted to the surefire plugin.

          • 2. Re: Maven and url stream handlers
            Paul Gier Master

            I updated the version of the surefire plugin (2.3 -> 2.4.1) and the test failures went away. The newer plugin didn't appear to break anything else, so all the mc modules now use the newer surefire plugin.

            • 3. Re: Maven and url stream handlers
              Adrian Brock Master

              That fixed it. I also removed the hack from the older tests. :-)