MyFaces Core
  1. MyFaces Core
  2. MYFACES-2548

META-INF resource lookup in OSGi environment

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0-beta-2
    • Fix Version/s: 2.0.0-beta-2
    • Component/s: General
    • Labels:
      None

      Description

      MyFaces uses context class loader to lookup META-INF resources. This works fine in a regular Java environment but breaks in OSGi. One easy solution for this would be to first ask the CCL for the resource and if none is found ask the surrounding class class loader for that resource (assuming the resource we are looking for lives in the same jar as the class loading it), i.e.:

      URL foo = getContextClassLoader().getResource("META-INF/foo");
      if (foo == null)

      { foo = getClass().getClassLoader().getResource("META-INF/foo"); }

      There are a few places in MyFaces code that would need to be updated to use this fallback approach. For example in IncludeHandler.java and ErrorPageWriter.java.

      I also noticed that for some reason the myfaces-dev-debug.xml and myfaces-dev-error.xml live in the api module. They seem to be only used the impl module so they shouldn't really be needed in the api module.

        Issue Links

          Activity

          Hide
          Jarek Gawor added a comment -

          Proposed patch. The patch checks the surrounding class class loader for the given resource if lookup using the context class loader failed.
          This is not included in the patch but the rsc/myfaces-dev-debug.xml and rsc/myfaces-dev-error.xml files will also need to be moved from api to impl module.

          Show
          Jarek Gawor added a comment - Proposed patch. The patch checks the surrounding class class loader for the given resource if lookup using the context class loader failed. This is not included in the patch but the rsc/myfaces-dev-debug.xml and rsc/myfaces-dev-error.xml files will also need to be moved from api to impl module.

            People

            • Assignee:
              Jakob Korherr
              Reporter:
              Jarek Gawor
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development