MyFaces Core
  1. MyFaces Core
  2. MYFACES-1896

FacesConfigurator version check incorrect

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2.2
    • Fix Version/s: 1.2.8
    • Component/s: None
    • Labels:
      None

      Description

      The FacesConfigurator does some checks on whether there are multiple versions of Tomahawk and MyFaces in the classpath. This check is incorrect, in the sense that it can, and will, log incorrect error messages.

      This problem occurs when using the jar from the tomahawk-facelets project (http://code.google.com/p/tomahawk-facelets), of which I'm one of the maintainers. The current release is called tomahawk-facelets-1.1.6.2.jar, which gives the following error:

      ERROR FacesConfigurator?:404 - You are using the MyFaces?-package : tomahawk in different versions; first (and probably used) version is : 1.1.6, currently encountered version is : facelets-taglib. This will cause undesired behaviour. Please clean out your class-path. The first encountered version is loaded from : file:/G:/Development/IdeaProjects/blokart/out/exploded/blokartWeb/WEB-INF/lib/tomahawk-1.1.6.jar. The currently encountered version is loaded from : jar:file:/G:/Development/IdeaProjects/blokart/out/exploded/blokartWeb/WEB-INF/lib/tomahawk-facelets-taglib.jar!/META-INF/MANIFEST.MF

      However, this jar just contains taglibs and some supporting class files. So the error is logged without a valid reason.

      I've looked at the code in the FacesConfigurator and have seen that the checks can be improved, e.g. using the following regular expression for getting the version number of Tomahawk: tomahawk-(\d\.\d\.\d)

      1. MYFACES-1896.patch
        21 kB
        Simon-Pierre Béliveau
      2. MYFACES-1896-v2.patch
        22 kB
        Simon Lessard

        Activity

        Hide
        Leonardo Uribe added a comment -

        In the latest code of tomahawk, facelets support is available (thanks to myfaces-builder-plugin), so this problem does not appear anymore.

        At first view, the bug should be on org.apache.myfaces.config.FacesConfigurator method checkJar. But this is used only for log info, so the error does not affect the working of the library.

        Show
        Leonardo Uribe added a comment - In the latest code of tomahawk, facelets support is available (thanks to myfaces-builder-plugin), so this problem does not appear anymore. At first view, the bug should be on org.apache.myfaces.config.FacesConfigurator method checkJar. But this is used only for log info, so the error does not affect the working of the library.
        Hide
        Simon-Pierre Béliveau added a comment -

        The patch uses regular expressions to compare the different jars.
        Also, unlike the original version, it compares all the jars in the classpath, not only predefined MyFaces libraries.

        Show
        Simon-Pierre Béliveau added a comment - The patch uses regular expressions to compare the different jars. Also, unlike the original version, it compares all the jars in the classpath, not only predefined MyFaces libraries.
        Hide
        Simon Lessard added a comment -

        Here's another version of the patch maintaining the exact same behavior as before (checking only myfaces libs) while the original was able to check all libs. Also removed System.out.println that shouldn't be part of the patch and changed tabs to 4 spaces to survive checkstyle. I'm not applying the patch on core trunks since the patch use JDK 5 features (generics) and core 1.1.x don't allow that. I also prefer to wait for someone more active on 1.2.x to apply it on the trunks. I feel safe to add it on 2.0.alpha branch though.

        Show
        Simon Lessard added a comment - Here's another version of the patch maintaining the exact same behavior as before (checking only myfaces libs) while the original was able to check all libs. Also removed System.out.println that shouldn't be part of the patch and changed tabs to 4 spaces to survive checkstyle. I'm not applying the patch on core trunks since the patch use JDK 5 features (generics) and core 1.1.x don't allow that. I also prefer to wait for someone more active on 1.2.x to apply it on the trunks. I feel safe to add it on 2.0.alpha branch though.
        Hide
        Wolfgang Klaus added a comment -

        When applying the patch please extend the regular expression because when runnig MyFaces in Borland Enterprise Server the beginning of the Jar-URL is not "jar:" it is "besjar:" and "file:" is missing.

        The following Regex will also match this:
        public static final String REGEX_LIBRARY = "(bes)?jar(file:)+.*/(.+)-" +
        "(\\d+)(\\.(\\d+)(\\.(\\d+)(\\.(
        d+))?)?)?(-SNAPSHOT)?" +
        "
        .jar)!/META-INF/MANIFEST.MF";

        If this patch wouldn't be applied I can give you a patch for the old checkjar method.

        Show
        Wolfgang Klaus added a comment - When applying the patch please extend the regular expression because when runnig MyFaces in Borland Enterprise Server the beginning of the Jar-URL is not "jar:" it is "besjar:" and "file:" is missing. The following Regex will also match this: public static final String REGEX_LIBRARY = "(bes)?jar ( file:)+.*/(.+)- " + "(\\d+)(\\.(\\d+)(\\.(\\d+)(\\.( d+))?)?)?(-SNAPSHOT)?" + " .jar)!/META-INF/MANIFEST.MF"; If this patch wouldn't be applied I can give you a patch for the old checkjar method.
        Hide
        Leonardo Uribe added a comment -

        I have checked the code proposed and committed a variation of this patch. The regex committed is this:

        public static final String REGEX_LIBRARY = "((jar)?(besjar)?(wsjar)?(zip)?)?file:.*/(.+)-" +
        "(\\d+)(\\.(\\d+)(\\.(\\d+)(\\.(
        d+))?)?)?(-SNAPSHOT)?" +
        "
        .jar)!/META-INF/MANIFEST.MF";

        some additional constants were added, and the testing code was moved to a test class.

        Show
        Leonardo Uribe added a comment - I have checked the code proposed and committed a variation of this patch. The regex committed is this: public static final String REGEX_LIBRARY = "((jar)?(besjar)?(wsjar)?(zip)?)? file:.*/(.+)- " + "(\\d+)(\\.(\\d+)(\\.(\\d+)(\\.( d+))?)?)?(-SNAPSHOT)?" + " .jar)!/META-INF/MANIFEST.MF"; some additional constants were added, and the testing code was moved to a test class.

          People

          • Assignee:
            Leonardo Uribe
            Reporter:
            Hilbert Schraal
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development