Maven 2 & 3

ClassCastException when building settings.xml with profiles that have activeByDefault set

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Blocker Blocker
  • Resolution: Fixed
  • Affects Version/s: 2.0.10
  • Fix Version/s: 2.0.11, 2.1.0-M1
  • Component/s: Settings
  • Labels:
    None
  • Complexity:
    Intermediate
  • Number of attachments :
    0

Description

from Paul Benedict:

I tried RC5 and got this weird error.

> >c:\dev\apache-maven-2.0.10-RC5\bin\mvn.bat site:deploy
---------------------------------------------------
constituent[0]:
file:/c:/Dev/apache-maven-2.0.10-RC5/bin/../lib/maven-2.0.10-RC5-uber.jar
---------------------------------------------------
java.lang.ClassCastException: Settings.addActiveProfiles(string)
parameter must be instanceof java.lang.String
        at org.apache.maven.settings.Settings.addActiveProfile(Settings.java:112)
        at org.apache.maven.settings.DefaultMavenSettingsBuilder.activateDefaultProfiles(DefaultMavenSettingsBuilder.jav
a:198)
        at org.apache.maven.settings.DefaultMavenSettingsBuilder.buildSettings(DefaultMavenSettingsBuilder.java:178)
        at org.apache.maven.settings.DefaultMavenSettingsBuilder.buildSettings(DefaultMavenSettingsBuilder.java:154)
        at org.apache.maven.settings.DefaultMavenSettingsBuilder.buildSettings(DefaultMavenSettingsBuilder.java:142)
        at org.apache.maven.cli.MavenCli.buildSettings(MavenCli.java:345)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:201)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)

Then, in a later message:

When I reinstalled 2.0.10-RC5, it ran fine. Then I realized my
reinstall didn't include my custom settings.xml, but once I put that
back into /conf, everything went bonkers again. So that's where the
problem is.

You can reproduce the problem by doing the following:
- Edit the original settings.xml that comes with Maven
- Within <profiles>, add this:

<profile>
  <activation>
    <activeByDefault>true</activeByDefault>
  </activation>
</profile>

The exception from my previous email should then be given:
java.lang.ClassCastException: Settings.addActiveProfiles(string)
parameter must be instanceof java.lang.String

Activity

Hide
John Casey added a comment -

fixed by assigning profile-id of 'default' when none is specified in a settings-sourced profile.

Show
John Casey added a comment - fixed by assigning profile-id of 'default' when none is specified in a settings-sourced profile.
Hide
John Casey added a comment -

Adding fix-for for both 2.0.10 and 2.1.0-M1, since 2.1.0-M1 will actually be released first and may not incorporate all of the eventual issue fixes released in 2.0.10.

Show
John Casey added a comment - Adding fix-for for both 2.0.10 and 2.1.0-M1, since 2.1.0-M1 will actually be released first and may not incorporate all of the eventual issue fixes released in 2.0.10.
Hide
Stephen Denne added a comment -

I just installed 2.0.10 release version, and my first use had the same symptoms as this issue. I can work around it by adding an id element (with any value) to the single profile I had defined.

Show
Stephen Denne added a comment - I just installed 2.0.10 release version, and my first use had the same symptoms as this issue. I can work around it by adding an id element (with any value) to the single profile I had defined.
Hide
Benjamin Bentmann added a comment -

Fixed for 2.0.x in r746038.

Show
Benjamin Bentmann added a comment - Fixed for 2.0.x in r746038.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: