Maven Surefire
  1. Maven Surefire
  2. SUREFIRE-118

Cannot override read-only parameter: classpathElements

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.5.2 (2.1.2 plugin), 2.0 (2.2 plugin)
    • Fix Version/s: 2.4
    • Component/s: None
    • Labels:
      None
    • Patch Submitted:
      Yes
    • Number of attachments :
      1

      Description

      When calling "mvn site" on a multi-module project the goal "surefire:test" fails for the second project:
      Error configuring: org.apache.maven.plugins:maven-surefire-plugin. Reason: ERROR: Cannot override read-only parameter: classpathElements in goal: surefire:test

      "mvn test" works and runs the tests on all modules.

        Issue Links

          Activity

          Hide
          Jean-Laurent de Morlhon added a comment -

          this is still happening with a fresh build of the plugin with svn at revision 1496

          Show
          Jean-Laurent de Morlhon added a comment - this is still happening with a fresh build of the plugin with svn at revision 1496
          Hide
          Brett Porter added a comment -

          what part of the site is failing? surefire-report, or cobertura, or something else?

          Show
          Brett Porter added a comment - what part of the site is failing? surefire-report, or cobertura, or something else?
          Hide
          David J. M. Karlsen added a comment -

          And what are your effective <surefire> settings for each artifact.
          The variable is readonly, and the configuration may be errorneous?

          Show
          David J. M. Karlsen added a comment - And what are your effective <surefire> settings for each artifact. The variable is readonly, and the configuration may be errorneous?
          Hide
          Zarar Siddiqi added a comment -

          OK, I'm trying to run StrutsTestCase with Maven 2.x and need the web.xml and struts-config.xml to be in the classpath, which they are not by default.

          So, I have the following configuration for the surefire plugin:

          <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.2</version>
          <configuration>
          <classpathElements>
          <classpathElement>target/$

          {project.artifactId}-${project.version}</classpathElement>
          </classpathElements>
          </configuration>
          </plugin>

          And this expectedly yields:

          Error configuring: org.apache.maven.plugins:maven-surefire-plugin. Reason: ERROR: Cannot override read-only parameter: classpathElements in goal: surefire:test

          The reason this is expected is because an explanation is provided here:

          http://www.nabble.com/testing-webapp-with-surefire-tf519140.html#a1403158

          Brett Porter has recommended requesting another element called additionalClasspathElements to be added which would not be read-only and thus allow for additional classpath elements to be added.

          I tried that using the following but it didn't get me anywhere.

          <additionalClasspathElements>
          <classpathElement>target/${project.artifactId}

          -$

          {project.version}

          </classpathElement>
          </additionalClasspathElements>

          Any ideas?

          Show
          Zarar Siddiqi added a comment - OK, I'm trying to run StrutsTestCase with Maven 2.x and need the web.xml and struts-config.xml to be in the classpath, which they are not by default. So, I have the following configuration for the surefire plugin: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.2</version> <configuration> <classpathElements> <classpathElement>target/$ {project.artifactId}-${project.version}</classpathElement> </classpathElements> </configuration> </plugin> And this expectedly yields: Error configuring: org.apache.maven.plugins:maven-surefire-plugin. Reason: ERROR: Cannot override read-only parameter: classpathElements in goal: surefire:test The reason this is expected is because an explanation is provided here: http://www.nabble.com/testing-webapp-with-surefire-tf519140.html#a1403158 Brett Porter has recommended requesting another element called additionalClasspathElements to be added which would not be read-only and thus allow for additional classpath elements to be added. I tried that using the following but it didn't get me anywhere. <additionalClasspathElements> <classpathElement>target/${project.artifactId} -$ {project.version} </classpathElement> </additionalClasspathElements> Any ideas?
          Hide
          Zarar Siddiqi added a comment -

          I've created a patch against revision 450675 which fixes this issue and allows you to specify additional classpaths:

          <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <configuration>
          <additionalClasspathElements>
          <additionalClasspathElement>path/to/additional/resources</additionalClasspathElement>
          </additionalClasspathElements>
          </configuration>
          </plugin>

          This patch does pretty much the same thing as the one supplied in MSUREFIRE-153 but I can't understand why that one hasn't been applied.

          I'm using this for now.

          Show
          Zarar Siddiqi added a comment - I've created a patch against revision 450675 which fixes this issue and allows you to specify additional classpaths: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <additionalClasspathElements> <additionalClasspathElement>path/to/additional/resources</additionalClasspathElement> </additionalClasspathElements> </configuration> </plugin> This patch does pretty much the same thing as the one supplied in MSUREFIRE-153 but I can't understand why that one hasn't been applied. I'm using this for now.
          Hide
          Peter Anning added a comment -

          I don't want to patch core maven I've done this before and it leads to a maintenance headache. For now I am running Junit via the ant plugin but this is not the point of maven. Please can we get this into the core asap.

          Cheers
          Peter

          Show
          Peter Anning added a comment - I don't want to patch core maven I've done this before and it leads to a maintenance headache. For now I am running Junit via the ant plugin but this is not the point of maven. Please can we get this into the core asap. Cheers Peter
          Hide
          Dan Fabulich added a comment -

          Fixed and integration tested in revision 597783.

          Show
          Dan Fabulich added a comment - Fixed and integration tested in revision 597783.
          Hide
          David Hoffer added a comment -

          Is it possible to specify the classpath load order of existing dependencies?

          I have a case where maven installs & deploys work find but site-deploy does not. The reason is the the order of the class path entries in the surefirebooter jar is different. I need to make sure that an artifact with overrides is loaded first. I don't need to add additional cp elements just specify order.

          Can this be done somehow?

          -Dave

          Show
          David Hoffer added a comment - Is it possible to specify the classpath load order of existing dependencies? I have a case where maven installs & deploys work find but site-deploy does not. The reason is the the order of the class path entries in the surefirebooter jar is different. I need to make sure that an artifact with overrides is loaded first. I don't need to add additional cp elements just specify order. Can this be done somehow? -Dave
          Hide
          lisak added a comment -

          Guys I would need to add 200 jars on classpath to boot up Liferay portal :

          <additionalClasspathElements>
          	<additionalClasspathElement>
          		/opt/liferay/portal/lib/development/*
          	</additionalClasspathElement>
          	<additionalClasspathElement>
          		/opt/liferay/portal/lib/global/*
          	</additionalClasspathElement>
          	<additionalClasspathElement>
          		/opt/liferay/portal/lib/portal/*
          	</additionalClasspathElement>
          </additionalClasspathElements>
          

          but it doesn't work. Neither *.jar wildcard ... Although

          /opt/liferay/portal/lib/portal/c3p0.jar

          works.

          I have really hard times to manage to debug surefire plugin. I can debug all other maven plugins remotely via Eclipse, but a breakpoint in AbstractSurefireMojo is just not triggered...

          Show
          lisak added a comment - Guys I would need to add 200 jars on classpath to boot up Liferay portal : <additionalClasspathElements> <additionalClasspathElement> /opt/liferay/portal/lib/development/* </additionalClasspathElement> <additionalClasspathElement> /opt/liferay/portal/lib/global/* </additionalClasspathElement> <additionalClasspathElement> /opt/liferay/portal/lib/portal/* </additionalClasspathElement> </additionalClasspathElements> but it doesn't work. Neither *.jar wildcard ... Although /opt/liferay/portal/lib/portal/c3p0.jar works. I have really hard times to manage to debug surefire plugin. I can debug all other maven plugins remotely via Eclipse, but a breakpoint in AbstractSurefireMojo is just not triggered...

            People

            • Assignee:
              Unassigned
              Reporter:
              Jesper Zedlitz
            • Votes:
              6 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: