Uploaded image for project: 'Maven Shade Plugin'
  1. Maven Shade Plugin
  2. MSHADE-183

Getting "Error creating shaded jar: java.util.jar.Attributes cannot be cast to java.lang.String" error when using ManifestResourceTransformer with Maven 3.2.5

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3
    • 2.4
    • None
    • Patch

    Description

      If you are using the ManifestResourceTransformer with empty values in the configuration you will get a "Error creating shaded jar: java.util.jar.Attributes cannot be cast to java.lang.String" error with Maven 3.2.5.

      Here as an example config that causes the problem

             
      <configuration>
        <transformers>
          <transformer
              implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
            <manifestEntries>
              <Main-Class>com.mycompany.app.App</Main-Class>
              <Implementation-Build></Implementation-Build>
            </manifestEntries>
          </transformer>
        </transformers>
      </configuration>
      

      I'm not sure what changed in populating the manifestEntries map but it looks like the manifestEntries.entrySet() in ManifestResourceTransformer is now getting back Attributes objects for the null values instead of null. When the transformer calls getValue() on the Attributes object you get the error.

      The fix was to make manifestEntries a Map<String, Object> instead of Map<String, Attributes>.

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            khmarbaise Karl Heinz Marbaise
            sqcheister Chris Heisterkamp
            Votes:
            3 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment