Uploaded image for project: 'Maven WAR Plugin'
  1. Maven WAR Plugin
  2. MWAR-405

Workaround XStream incompatibility with Java9

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 3.0.0
    • Fix Version/s: 3.1.0
    • Component/s: None
    • Labels:
      None

      Description

      The problem is that XStreams tries to access "comparator" field of java.util.TreeMap and this is forbidden in Java9

      Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.Comparator java.util.TreeMap.comparator accessible: module java.base does not "opens java.util" to unnamed module
      Happens while initializing org.apache.maven.plugins.war.util.WebappStructureSerializer
      

      A possibile workaround is to change the initialization of XStreams in a way that only useful converters are registers, thus bypassing the problem

        Issue Links

          Activity

          Hide
          hudson Hudson added a comment -

          SUCCESS: Integrated in Jenkins build maven-plugins #8935 (See https://builds.apache.org/job/maven-plugins/8935/)
          MWAR-405 Workaround XStream incompatibility with Java9
          Contributed by Enrico Olivelli, reviewed and applied by Robert Scholte

          this closes #112 (rfscholte: http://svn.apache.org/viewvc/?view=rev&rev=1792363)

          • (edit) maven-war-plugin/pom.xml
          • (edit) maven-war-plugin/src/main/java/org/apache/maven/plugins/war/util/WebappStructureSerializer.java
          Show
          hudson Hudson added a comment - SUCCESS: Integrated in Jenkins build maven-plugins #8935 (See https://builds.apache.org/job/maven-plugins/8935/ ) MWAR-405 Workaround XStream incompatibility with Java9 Contributed by Enrico Olivelli, reviewed and applied by Robert Scholte this closes #112 (rfscholte: http://svn.apache.org/viewvc/?view=rev&rev=1792363 ) (edit) maven-war-plugin/pom.xml (edit) maven-war-plugin/src/main/java/org/apache/maven/plugins/war/util/WebappStructureSerializer.java
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user asfgit closed the pull request at:

          https://github.com/apache/maven-plugins/pull/112

          Show
          githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/maven-plugins/pull/112
          Hide
          rfscholte Robert Scholte added a comment -

          Fixed in r1792363
          Thanks for the patch!

          Show
          rfscholte Robert Scholte added a comment - Fixed in r1792363 Thanks for the patch!
          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user eolivelli reopened a pull request:

          https://github.com/apache/maven-plugins/pull/112

          MWAR-405 Workaround XStream incompatibility with Java9

          This is a proof-of-concept implementation of a possible way to word-around the actual incompatibility of xstreams default converters with java9.
          As the maven-war-plugin does not need all of the converters (like TreeMapConverter which is the primary cause of the issue) we can just register only the needed ones and bypass the java9 issue

          see

          Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.Comparator java.util.TreeMap.comparator accessible: module java.base does not "opens java.util" to unnamed module
          Happens while initializing org.apache.maven.plugins.war.util.WebappStructureSerializer

          at
          https://cwiki.apache.org/confluence/display/MAVEN/Java+9+-+Jigsaw

          this PR is just a proof-of-concept, there is an email thread on the dev list. If the idea is accepted I will submit a JIRA and official PR (some code cleanup is needed at least)

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/eolivelli/maven-plugins maven-war-plugin-easy-fix

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/maven-plugins/pull/112.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #112


          commit 9bd4409a309d461ffc77dda06b11d295797d3b27
          Author: eolivelli <eolivelli@apache.org>
          Date: 2017-04-11T08:07:36Z

          MWAR-405 Workaround XStream incompatibility with Java9
          Register only used Converters


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user eolivelli reopened a pull request: https://github.com/apache/maven-plugins/pull/112 MWAR-405 Workaround XStream incompatibility with Java9 This is a proof-of-concept implementation of a possible way to word-around the actual incompatibility of xstreams default converters with java9. As the maven-war-plugin does not need all of the converters (like TreeMapConverter which is the primary cause of the issue) we can just register only the needed ones and bypass the java9 issue see Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.Comparator java.util.TreeMap.comparator accessible: module java.base does not "opens java.util" to unnamed module Happens while initializing org.apache.maven.plugins.war.util.WebappStructureSerializer at https://cwiki.apache.org/confluence/display/MAVEN/Java+9+-+Jigsaw this PR is just a proof-of-concept, there is an email thread on the dev list. If the idea is accepted I will submit a JIRA and official PR (some code cleanup is needed at least) You can merge this pull request into a Git repository by running: $ git pull https://github.com/eolivelli/maven-plugins maven-war-plugin-easy-fix Alternatively you can review and apply these changes as the patch at: https://github.com/apache/maven-plugins/pull/112.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #112 commit 9bd4409a309d461ffc77dda06b11d295797d3b27 Author: eolivelli <eolivelli@apache.org> Date: 2017-04-11T08:07:36Z MWAR-405 Workaround XStream incompatibility with Java9 Register only used Converters
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user eolivelli closed the pull request at:

          https://github.com/apache/maven-plugins/pull/112

          Show
          githubbot ASF GitHub Bot added a comment - Github user eolivelli closed the pull request at: https://github.com/apache/maven-plugins/pull/112
          Hide
          eolivelli Enrico Olivelli added a comment -

          I have updated the patch, listing only the used converters.

          Notes:

          • the IntConverter is needed in order to build real webapps (I have used my projects), but no test case reproduces the error I have when I disable that converter. Should I add a test case which covers the need for IntConverter ?
          • The lack of any of the other Converters leads to failing test cases, even on Java8
          Show
          eolivelli Enrico Olivelli added a comment - I have updated the patch, listing only the used converters. Notes: the IntConverter is needed in order to build real webapps (I have used my projects), but no test case reproduces the error I have when I disable that converter. Should I add a test case which covers the need for IntConverter ? The lack of any of the other Converters leads to failing test cases, even on Java8
          Hide
          eolivelli Enrico Olivelli added a comment - - edited

          I can clean up the list and complete the patch.
          I have some cycle today.
          If you want you can assign this issue to me

          Show
          eolivelli Enrico Olivelli added a comment - - edited I can clean up the list and complete the patch. I have some cycle today. If you want you can assign this issue to me
          Hide
          rfscholte Robert Scholte added a comment -

          I actually like this solution and should be easy to apply. We can predict quite well which converters we need.

          Show
          rfscholte Robert Scholte added a comment - I actually like this solution and should be easy to apply. We can predict quite well which converters we need.
          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user eolivelli reopened a pull request:

          https://github.com/apache/maven-plugins/pull/112

          MWAR-405 Workaround XStream incompatibility with Java9

          This is a proof-of-concept implementation of a possible way to word-around the actual incompatibility of xstreams default converters with java9.
          As the maven-war-plugin does not need all of the converters (like TreeMapConverter which is the primary cause of the issue) we can just register only the needed ones and bypass the java9 issue

          see

          Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.Comparator java.util.TreeMap.comparator accessible: module java.base does not "opens java.util" to unnamed module
          Happens while initializing org.apache.maven.plugins.war.util.WebappStructureSerializer

          at
          https://cwiki.apache.org/confluence/display/MAVEN/Java+9+-+Jigsaw

          this PR is just a proof-of-concept, there is an email thread on the dev list. If the idea is accepted I will submit a JIRA and official PR (some code cleanup is needed at least)

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/eolivelli/maven-plugins maven-war-plugin-easy-fix

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/maven-plugins/pull/112.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #112


          commit d26db922d07425eb74d0cf1b42c1234f6953cd96
          Author: eolivelli <eolivelli@gmail.com>
          Date: 2017-04-11T08:07:36Z

          Load only useful XStream converters


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user eolivelli reopened a pull request: https://github.com/apache/maven-plugins/pull/112 MWAR-405 Workaround XStream incompatibility with Java9 This is a proof-of-concept implementation of a possible way to word-around the actual incompatibility of xstreams default converters with java9. As the maven-war-plugin does not need all of the converters (like TreeMapConverter which is the primary cause of the issue) we can just register only the needed ones and bypass the java9 issue see Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.Comparator java.util.TreeMap.comparator accessible: module java.base does not "opens java.util" to unnamed module Happens while initializing org.apache.maven.plugins.war.util.WebappStructureSerializer at https://cwiki.apache.org/confluence/display/MAVEN/Java+9+-+Jigsaw this PR is just a proof-of-concept, there is an email thread on the dev list. If the idea is accepted I will submit a JIRA and official PR (some code cleanup is needed at least) You can merge this pull request into a Git repository by running: $ git pull https://github.com/eolivelli/maven-plugins maven-war-plugin-easy-fix Alternatively you can review and apply these changes as the patch at: https://github.com/apache/maven-plugins/pull/112.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #112 commit d26db922d07425eb74d0cf1b42c1234f6953cd96 Author: eolivelli <eolivelli@gmail.com> Date: 2017-04-11T08:07:36Z Load only useful XStream converters
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user eolivelli closed the pull request at:

          https://github.com/apache/maven-plugins/pull/112

          Show
          githubbot ASF GitHub Bot added a comment - Github user eolivelli closed the pull request at: https://github.com/apache/maven-plugins/pull/112

            People

            • Assignee:
              rfscholte Robert Scholte
              Reporter:
              eolivelli Enrico Olivelli
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development