jersey
  1. jersey
  2. JERSEY-2336

Support for META-INF/services discovery for UriSchemeResourceFinderFactories

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.5.1
    • Fix Version/s: 2.12
    • Component/s: core
    • Labels:
      None

      Description

      WebSphere uses the URL scheme 'wsjar://...' for the JARs it loads rather than the standard 'jar://...'. This means that Jersey applications hosted by WebSphere don't work because ResourceConfig.packages() and PackageNamesScanner can't resolve the URLs.

      Currently I'm working around this issue by registering a PackageNamesScanner.ResourcesProvider that rewrites the 'wsjar' URLs to 'jar' before loading them, however this might be fragile (I'm relying on WebSphere's classloader to resolve jar URLs when it's expecting wsjar URLs, which might not be safe) and I think the correct solution is to register a new ResourceFinderFactory that handles the wsjar URL scheme, but currently there's no way to do this other than duplicating and extending much of the PackageNamesScanner code.

      The PackageNamesScanner constructor has these lines:

      //        TODO - Services?
      //        for (UriSchemeResourceFinderFactory s : ServiceFinder.find(UriSchemeResourceFinderFactory.class)) {
      //            add(s);
      //        }
      

      If this support were in place then I could register a new factory for the wsjar scheme.

        Issue Links

          Activity

          Hide
          Michal Gajdos added a comment -

          Thanks for suggestion. Maybe it would be enough to add new scheme into JarZipSchemeResourceFinderFactory, but the suggestion is more general.

          Show
          Michal Gajdos added a comment - Thanks for suggestion. Maybe it would be enough to add new scheme into JarZipSchemeResourceFinderFactory , but the suggestion is more general.
          Hide
          Michael Iles added a comment -

          Yes simply adding wsjar to the list of schemes in JarZipSchemeResourceFinderFactory would do it:

          class JarZipSchemeResourceFinderFactory implements UriSchemeResourceFinderFactory {
          
              @Override
              public Set<String> getSchemes() {
                  return new HashSet<String>(Arrays.asList("jar", "zip", "wsjar"));
              }
          
          Show
          Michael Iles added a comment - Yes simply adding wsjar to the list of schemes in JarZipSchemeResourceFinderFactory would do it: class JarZipSchemeResourceFinderFactory implements UriSchemeResourceFinderFactory { @Override public Set< String > getSchemes() { return new HashSet< String >(Arrays.asList( "jar" , "zip" , "wsjar" )); }
          Hide
          navarroe added a comment - - edited

          First time contributing to Jersey, so hopefully I did this right Enclosed find the link to a gist that I created with a patch fix for this bug along with a test case. I went with Michal's suggestion of adding the scheme to the existing JarZipSchemeResourceFinderFactory class.

          https://gist.github.com/d2caed53ee6ebd819189

          Regards,
          Eric

          Show
          navarroe added a comment - - edited First time contributing to Jersey, so hopefully I did this right Enclosed find the link to a gist that I created with a patch fix for this bug along with a test case. I went with Michal's suggestion of adding the scheme to the existing JarZipSchemeResourceFinderFactory class. https://gist.github.com/d2caed53ee6ebd819189 Regards, Eric
          Hide
          Michal Gajdos added a comment -

          Hi Eric,

          can you, please, create a pull request (https://github.com/jersey/jersey) and also sign an OCA (see [1] and [2]). After we receive a confirmation about your OCA we'll merge the request.

          [1] https://jersey.java.net/scm.html#/Submitting_Patches_and_Contribute_Code
          [2] http://www.oracle.com/technetwork/community/oca-486395.html

          Thanks,
          Michal

          Show
          Michal Gajdos added a comment - Hi Eric, can you, please, create a pull request ( https://github.com/jersey/jersey ) and also sign an OCA (see [1] and [2] ). After we receive a confirmation about your OCA we'll merge the request. [1] https://jersey.java.net/scm.html#/Submitting_Patches_and_Contribute_Code [2] http://www.oracle.com/technetwork/community/oca-486395.html Thanks, Michal
          Hide
          navarroe added a comment -

          Hi Michal,
          Pull request created. I had already submitted my OCA on Friday (July 11th)

          Let me know if there's anything else I need to do.

          Thanks,
          Eric

          Show
          navarroe added a comment - Hi Michal, Pull request created. I had already submitted my OCA on Friday (July 11th) Let me know if there's anything else I need to do. Thanks, Eric

            People

            • Assignee:
              Michal Gajdos
              Reporter:
              Michael Iles
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: