21

I get this WARNING when I try to build my maven project. I have searched google but with no luck. This is really annoying since I wanna release my project but it wont work with this warning (I think). The build is successful, but when I try to deploy the war file it doesen't work (no error message). The only warning I can find when I build the project is this:

[WARNING] The requested profile "projectname" could not be activated because it does not exist.
benskiiii
  • 439
  • 3
  • 11
  • 23
  • What command are you using to run maven? – Louis Fellows Jul 12 '13 at 11:26
  • Im doing it auto in spring. package with no tests and show debugs command only. Do you have any m example I can try? – benskiiii Jul 12 '13 at 11:28
  • 1
    Obviously the "projectname" profile is added to the Maven command. And Maven realises in the end that the profile didn't exist in the pom(s) – Tome Jul 12 '13 at 13:26
  • I checked for that too, added the tag profile name or what it's called as well. Still didn't work. – benskiiii Jul 14 '13 at 21:41
  • If you are running ```mvn``` command with ```-P "profilename"``` flag and getting this error, you need to ensure that the ```pom.xml``` in the directory where you are running ```mvn``` command has ```***your-profile-details***```. – Naveen Kumar Feb 28 '23 at 19:55

4 Answers4

23

This happens when you have the following in your settings.xml (in your .m2 directory), and no profile with the id projectname.

<activeProfiles>
  <activeProfile>projectname</activeProfile>
</activeProfiles>
user3296624
  • 346
  • 4
  • 6
  • 14
    I have seen the warning mentioned in the question even when there IS a profile with a matching ID in the settings.xml file. Given my experience and that of my teammates, this doesn't seem to be the whole answer. – user944849 Aug 01 '14 at 13:28
  • It is curious it happen if you deactivate existing profile on command line. `mvn -P\!profileid clean install` `[WARNING] The requested profile "profileid" could not be activated because it does not exist.` – mirec Nov 10 '20 at 17:35
  • I get this warning even without having a settings.xml file... – devinbost Nov 19 '20 at 00:24
12

You need to configure your project pom.xml with the following profile:

<profiles>
    <profile>
        <id>**projectid**</id>
    </profile>
</profiles>
Eyal Sooliman
  • 1,876
  • 23
  • 29
4

If you run

MVN clean install

from command line and do not get the warning, but get it if you run it from Eclipse m2e plugin, check if you have set a profile in the (default) Run configuration.

In Eclipse Project Explorer, select the project, right click > Run As > Run Configurations. Check the m2 run configurations of your project. Check if you have "projectname", i.e. the profile mentioned in the WARNING is provided in the Profiles parameter. Remove the profile from the profiles form field in the dialog. The cause may be that you have had a in you pom.xml, and used it in the build. When you remove it from pom.xml - it remains in the run configuration, even if it does not show up in the project explorer's Maven context menu (Maven > Select Maven Profiles ...)

0

This can also happen if you have profile whose id contains a space, e.g.:

<settings>
    <profiles>
        <profile>
            <id>archiva repo</id>
        ...
thomas.mc.work
  • 6,404
  • 2
  • 26
  • 41