Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-5465

Solr Contrib "map-reduce" breaks Manifest of all other JAR files by adding a broken Main-Class attribute

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.7
    • Fix Version/s: 4.7, 4.8, 6.0
    • Component/s: None
    • Labels:
      None
    • Lucene Fields:
      New, Patch Available

      Description

      The addition of the Solr map-reduce contrib created a new "main.class" property, which is used by the jarify task. Currently only the map-reduce plugin actually set this property, soall other generated JAR files contain the following line:

      Main-Class: ${main.class}

      This happens because the ANT property "main.class" is undefined for most modules. Maybe this was added for one of the modules (I assume that the Solr-Morphline JARs use this attribute?). We should add some if/then/else structure to the <jarify/> task that only sets this property, if it is actually defined. Otherwise remove it (I think ANT does this automatically if its empty, means string-empty, have to try out)

      This leads to an error if the file is double-clicked or started via java -jar:

      C:\Users\Uwe Schindler\Desktop>java -jar lucene-core-4.7.0.jar
      Fehler: Hauptklasse ${main.class} konnte nicht gefunden oder geladen werden
      

      I opened this issue in LUCENE, because jar files from LUCENE and SOLR are affected.

      1. LUCENE-5465.patch
        6 kB
        Steve Rowe
      2. LUCENE-5465.patch
        1 kB
        Uwe Schindler

        Activity

        Hide
        steve_rowe Steve Rowe added a comment -

        Committed to trunk, branch_4x, and lucene_solr_4_7.

        Show
        steve_rowe Steve Rowe added a comment - Committed to trunk, branch_4x, and lucene_solr_4_7.
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 1570741 from Steve Rowe in branch 'dev/branches/lucene_solr_4_7'
        [ https://svn.apache.org/r1570741 ]

        LUCENE-5465: Solr Contrib map-reduce breaks Manifest of all other JAR files by adding a broken Main-Class attribute (merged trunk r1570738)

        Show
        jira-bot ASF subversion and git services added a comment - Commit 1570741 from Steve Rowe in branch 'dev/branches/lucene_solr_4_7' [ https://svn.apache.org/r1570741 ] LUCENE-5465 : Solr Contrib map-reduce breaks Manifest of all other JAR files by adding a broken Main-Class attribute (merged trunk r1570738)
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 1570739 from Steve Rowe in branch 'dev/branches/branch_4x'
        [ https://svn.apache.org/r1570739 ]

        LUCENE-5465: Solr Contrib map-reduce breaks Manifest of all other JAR files by adding a broken Main-Class attribute (merged trunk r1570738)

        Show
        jira-bot ASF subversion and git services added a comment - Commit 1570739 from Steve Rowe in branch 'dev/branches/branch_4x' [ https://svn.apache.org/r1570739 ] LUCENE-5465 : Solr Contrib map-reduce breaks Manifest of all other JAR files by adding a broken Main-Class attribute (merged trunk r1570738)
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 1570738 from Steve Rowe in branch 'dev/trunk'
        [ https://svn.apache.org/r1570738 ]

        LUCENE-5465: Solr Contrib map-reduce breaks Manifest of all other JAR files by adding a broken Main-Class attribute

        Show
        jira-bot ASF subversion and git services added a comment - Commit 1570738 from Steve Rowe in branch 'dev/trunk' [ https://svn.apache.org/r1570738 ] LUCENE-5465 : Solr Contrib map-reduce breaks Manifest of all other JAR files by adding a broken Main-Class attribute
        Hide
        thetaphi Uwe Schindler added a comment -

        Because we respin, we should backport this also to 4.7 - it is not risky. I don't like broken metadata.

        Show
        thetaphi Uwe Schindler added a comment - Because we respin, we should backport this also to 4.7 - it is not risky. I don't like broken metadata.
        Hide
        thetaphi Uwe Schindler added a comment -

        Cool, thanks for taking care. I was outside this evening and was thinking about how to solve this - very elegant! Congrats

        Show
        thetaphi Uwe Schindler added a comment - Cool, thanks for taking care. I was outside this evening and was thinking about how to solve this - very elegant! Congrats
        Hide
        steve_rowe Steve Rowe added a comment -

        The correct way to fix this is: As the manifest creator is already a ANT macro, we can use its feature to pass sub-elements (the attributes). Every module that wants to define something like the main-class manifest attribute can pass this directly as subelement to the macro.

        The attached patch does this; as a result, only the Solr map-reduce contrib gets the Main-Class manifest entry in its jar's META-INF/MANIFEST.MF.

        I found that in order to pass nested elements through multiple layers of macros, I had to un- and re-wrap the nested elements, using different element names at each level - otherwise the final element gets placed at the wrong level and Ant bitches that it doesn't expect the final element. So it's kludgy, but it works.

        Show
        steve_rowe Steve Rowe added a comment - The correct way to fix this is: As the manifest creator is already a ANT macro, we can use its feature to pass sub-elements (the attributes). Every module that wants to define something like the main-class manifest attribute can pass this directly as subelement to the macro. The attached patch does this; as a result, only the Solr map-reduce contrib gets the Main-Class manifest entry in its jar's META-INF/MANIFEST.MF . I found that in order to pass nested elements through multiple layers of macros, I had to un- and re-wrap the nested elements, using different element names at each level - otherwise the final element gets placed at the wrong level and Ant bitches that it doesn't expect the final element. So it's kludgy, but it works.
        Hide
        thetaphi Uwe Schindler added a comment -

        The correct way to fix this is: As the manifest creator is already a ANT macro, we can use its feature to pass sub-elements (the attributes). Every module that wants to define something like the main-class manifest attribute can pass this directly as subelement to the macro.

        Show
        thetaphi Uwe Schindler added a comment - The correct way to fix this is: As the manifest creator is already a ANT macro, we can use its feature to pass sub-elements (the attributes). Every module that wants to define something like the main-class manifest attribute can pass this directly as subelement to the macro.
        Hide
        thetaphi Uwe Schindler added a comment -

        This patch at least fixes the bug, it still creates an empty "Main-Class" Manifest entry. But this empty entry seems to have no effect, java -jar ignores it.

        Show
        thetaphi Uwe Schindler added a comment - This patch at least fixes the bug, it still creates an empty "Main-Class" Manifest entry. But this empty entry seems to have no effect, java -jar ignores it.
        Hide
        thetaphi Uwe Schindler added a comment -

        We might fix that issue, but I would completely remove that attribute on the Solr map-reduce contrib's JAR file. The JAR file is not self-contained (means maven-shaded), so you cannot really start it with java -jar, because the classpath is not complete.

        Maybe remove the "main.class" stuff from <jarify/>?

        Show
        thetaphi Uwe Schindler added a comment - We might fix that issue, but I would completely remove that attribute on the Solr map-reduce contrib's JAR file. The JAR file is not self-contained (means maven-shaded), so you cannot really start it with java -jar , because the classpath is not complete. Maybe remove the "main.class" stuff from <jarify/> ?

          People

          • Assignee:
            steve_rowe Steve Rowe
            Reporter:
            thetaphi Uwe Schindler
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development