Maven2: parent pom not found by TeamCity (even though the build works)

I have the following in my project's pom:

  <parent>
    <groupId>com.mycompany.myproject</groupId>
    <artifactId>uber-pom</artifactId>
    <version>4</version>
  </parent>


The maven2 build works fine both from command line and in TeamCity, com.mycompany.myproject:uber-pom:4 is downloaded from the repository. However, when I set the build number format to include %maven.project.version%, this variable does not get resolved. Furthermore, the Maven 2 tab of build configuration reports an error:

An error occurred during collecting Maven data: org.apache.maven.reactor.MavenExecutionException: Cannot find parent: com.mycompany.myproject:uber-pom for project: com.mycompany.myproject:project-name:jar:2.5.0-SNAPSHOT for project com.mycompany.myproject:project-name:jar:2.5.0-SNAPSHOT

A partial solution was to supply a <relativePath> in <parent> and modify the checkout rules so that the uber-pom is checked out together with project-name. This is not ideal though since I have to ensure that the version of uber-pom that is checked out always matches the version specified in project-name's pom -- otherwise the problem remains.

Is it a known problem and is there any solution or work-around?

Regards,
Maciek
0
40 comments
Avatar
Permanently deleted user

Hello, Maciek

What TeamCity version are you using?

0
Avatar
Permanently deleted user

Apologies, should have started from that: this is in TeamCity 5.1.3.

Regards,
Maciek

0
Avatar
Permanently deleted user

Could you please enable debug logging in teamcity-agent-log4j.xml, restart the agent, run the build and send me the teamcity-agent.log

Thank you

0
Avatar
Permanently deleted user

Sergey,

I sent the log file directly to you via e-mail. I had a look at the contents and noticed this:

[2010-09-06 12:23:25,430]   WARN -    jetbrains.buildServer.AGENT - Cannot find parent: com.mycompany.myproject:uber-pom for project: com.mycompany.myproject:project-name:jar:2.5.0-SNAPSHOT for project com.mycompany.myproject:project-name:jar:2.5.0-SNAPSHOT
org.apache.maven.reactor.MavenExecutionException: Cannot find parent: com.mycompany.myproject:uber-pom for project: com.mycompany.myproject:project-name:jar:2.5.0-SNAPSHOT for project com.mycompany.myproject:project-name:jar:2.5.0-SNAPSHOT
at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:404)
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:585)
at org.jetbrains.maven.embedder.MavenEmbedder.readProject(MavenEmbedder.java:527)
at org.jetbrains.maven.embedder.MavenEmbedder.readProject(MavenEmbedder.java:576)
at jetbrains.maven.MavenBuildService.readProject(MavenBuildService.java:290)
at jetbrains.maven.MavenBuildService.beforeProcessStarted(MavenBuildService.java:242)
at jetbrains.buildServer.agent.runner2.GenericCommandLineBuildProcess.start(GenericCommandLineBuildProcess.java:54)
at jetbrains.buildServer.agent.impl.runStages.CallRunnerStage.doBuildStage(CallRunnerStage.java:39)
at jetbrains.buildServer.agent.impl.BuildRunAction.callRunStage(BuildRunAction.java:115)
at jetbrains.buildServer.agent.impl.BuildRunAction.doStages(BuildRunAction.java:77)
at jetbrains.buildServer.agent.impl.BuildRunAction.access$000(BuildRunAction.java:17)
at jetbrains.buildServer.agent.impl.BuildRunAction$1.run(BuildRunAction.java:53)
at java.lang.Thread.run(Thread.java:595)
Caused by: org.apache.maven.project.ProjectBuildingException: Cannot find parent: com.mycompany.myproject:uber-pom for project: com.mycompany.myproject:project-name:jar:2.5.0-SNAPSHOT for project com.mycompany.myproject:project-name:jar:2.5.0-SNAPSHOT
at org.apache.maven.project.DefaultMavenProjectBuilder.assembleLineage(DefaultMavenProjectBuilder.java:1396)
at org.apache.maven.project.DefaultMavenProjectBuilder.buildInternal(DefaultMavenProjectBuilder.java:823)
at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromSourceFileInternal(DefaultMavenProjectBuilder.java:508)
at org.apache.maven.project.DefaultMavenProjectBuilder.build(DefaultMavenProjectBuilder.java:200)
at org.apache.maven.DefaultMaven.getProject(DefaultMaven.java:604)
at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:487)
at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:391)
... 15 more
Caused by: org.apache.maven.project.ProjectBuildingException: POM 'com.mycompany.myproject:uber-pom' not found in repository: Unable to download the artifact from any repository


  com.mycompany.myproject:uber-pom:pom:4


from the specified remote repositories:
  central (http://repo1.maven.org/maven2)


for project com.mycompany.myproject:uber-pom
at org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepository(DefaultMavenProjectBuilder.java:605)
at org.apache.maven.project.DefaultMavenProjectBuilder.assembleLineage(DefaultMavenProjectBuilder.java:1392)
... 21 more
Caused by: org.apache.maven.artifact.resolver.ArtifactNotFoundException: Unable to download the artifact from any repository


  com.mycompany.myproject:uber-pom:pom:4


from the specified remote repositories:
  central (http://repo1.maven.org/maven2)




at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:228)
at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:90)
at org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepository(DefaultMavenProjectBuilder.java:558)
... 22 more
Caused by: org.apache.maven.wagon.ResourceDoesNotExistException: Unable to download the artifact from any repository
at org.apache.maven.artifact.manager.DefaultWagonManager.getArtifact(DefaultWagonManager.java:404)
at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:216)
... 24 more


TeamCity is looking for the parent pom in the default maven repo only. The pom is in our local repo; I have configured the maven builder to use it by supplyling a path to settings.xml which specify this repo. It seems that this path is passed to maven when the project is built but not when the variables are resolved.
0
Avatar
Permanently deleted user

Thank you, Maciek.

You're right. The settings path isn't taken when resolving variables. This bug is already fixed in 6.0 EAP. As a workaround you can put your settings.xml into a default location in ~/.m2/ on the agent.
If this is not an option, I'll prepare a patch with the fix for you.

0
Avatar
Permanently deleted user

Putting settings.xml in ~/.m2 did the trick. Thanks very much for your help!

Regards,
Maciek

0
Avatar
Permanently deleted user

Where would I put the Maven settings file on a Windows system to fix this issue? It is not clear to me where the Build service is reading the Maven settings file from (the default location). Each of my projects point to c:\maven\settings.xml and use a custom Maven install at c:\maven\2.2.1. However, it's clear that when resolving Maven data in the UI that these settings are not respected (per this thread). I've tried placing my settings file at:

C:\Documents and Settings\All Users\.m2\settings.xml
C:\Documents and Settings\Default User\.m2\settings.xml
C:\teamcity\build\plugins\maven\conf\settings.xml (I installed my build agent at c:\teamcity\build)
C:\maven\2.2.1\conf\settings.xml

None of these locations resolved the issue in the UI when I click on the Maven2 tab. I still get:


An error occurred during collecting Maven data: org.apache.maven.reactor.MavenExecutionException: Cannot find parent: com.emc.vsi:emc-vsi-vsphere4-features for project: com.emc.vsi:emc-vsi-vsphere4-features-spo-common:dll:4.0.0-SNAPSHOT for project com.emc.vsi:emc-vsi-vsphere4-features-spo-common:dll:4.0.0-SNAPSHOT


I'm running Version 5.1.4 (build 13550) on Windows 2003 (I have to build .NET and Java else I'd just run it on a single Linux system).

Thanks for your help!

--
-a
0
Avatar
Permanently deleted user

Just FYI, my builds work without error. Here are the last several log entries:

[2010-09-26 21:29:00,483] WARN - er.maven.ServerMavenFacadeUtil - skipping this module subtree... [2010-09-26 21:29:00,483] WARN - impl.MavenMetadataProviderImpl - Error generating Maven metadata for build configuration SPO Common :: Trunk Build {id=bt6}: org.apache.maven.reactor.MavenExecutionException: Cannot find parent: com.emc.vsi:emc-vsi-vsphere4-features for project: com.emc.vsi:emc-vsi-vsphere4-features-spo-common:dll:4.0.0-SNAPSHOT for project com.emc.vsi:emc-vsi-vsphere4-features-spo-common:dll:4.0.0-SNAPSHOT [2010-09-26 21:32:41,421] INFO - rs.login.LoginSubmitController - Successful login with login name: kutzs [2010-09-26 21:37:27,983] WARN - impl.MavenMetadataProviderImpl - Error generating Maven metadata for build configuration VSI for vSphere4 :: Trunk Build {id=bt13}: org.apache.maven.reactor.MavenExecutionException: Cannot find parent: com.emc.vsi:emc-vsi for project: com.emc.vsi:emc-vsi-vsphere4:pom:4.0.0-SNAPSHOT for project com.emc.vsi:emc-vsi-vsphere4:pom:4.0.0-SNAPSHOT [2010-09-26 21:37:55,812] INFO - rs.login.LoginSubmitController - Successful login with login name: kutzs [2010-09-26 22:11:52,358] WARN - er.maven.ServerMavenFacadeUtil - error reading pom.xml jetbrains.buildServer.maven.MavenException: only whitespace content allowed before start tag and not \uef (position: START_DOCUMENT seen \uef... @1:1) at jetbrains.buildServer.maven.ServerMavenFacadeUtil.readModel(ServerMavenFacadeUtil.java:210) at jetbrains.buildServer.maven.ServerMavenFacadeUtil.buildTempPomStructure(ServerMavenFacadeUtil.java:136) at jetbrains.buildServer.maven.ServerMavenFacadeUtil.buildProjectWithModules(ServerMavenFacadeUtil.java:57) at jetbrains.buildServer.maven.ServerMavenFacade.buildProject(ServerMavenFacade.java:110) at jetbrains.buildServer.maven.metadata.impl.MavenMetadataProviderImpl.doGenerateMetadata(MavenMetadataProviderImpl.java:244) at jetbrains.buildServer.maven.metadata.impl.MavenMetadataProviderImpl.access$300(MavenMetadataProviderImpl.java:32) at jetbrains.buildServer.maven.metadata.impl.MavenMetadataProviderImpl$1.run(MavenMetadataProviderImpl.java:202) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) [2010-09-26 22:11:52,358] WARN - er.maven.ServerMavenFacadeUtil - skipping this module subtree... [2010-09-26 22:11:52,358] WARN - impl.MavenMetadataProviderImpl - Error generating Maven metadata for build configuration AssmemblyUtils :: Trunk Build {id=bt9}: org.apache.maven.reactor.MavenExecutionException: Could not find the model file &apos;C:\teamcity\server\temp\teamcity6467126389123183234maven\EMC.AssemblyUtils&apos;. for project unknown

0
Avatar
Permanently deleted user

Hello, Andrew

Is the specified parent pom a part of the project or stored in the repository?

0
Avatar
Permanently deleted user

The parent POMs are in the repository (which is specified in my settings.xml). The projects are checked out separately and thus the relative paths mean little on the build server. Also, I tediously went through all of the POMs and ensured that they were checked in as UTF-8 (instead of UTF-8Y or CPL1592 as Windows's editors are inclined to fark up a file's encoding).

--
-a

0
Avatar
Permanently deleted user

For displaying Maven 2 tab the project data is read on the TeamCity server. Agents don't participate in this. This means that you have to configure server-side settings separately. You can simply put your settings file at <TeamCity user home>/.m2 on the server machine and reload Maven data. For more details and options please take a look at http://confluence.jetbrains.net/display/TCD5/Maven+Support.

0
Avatar
Permanently deleted user

Pardon my ignorance, but where is the server's home directory with regards to where I should put the .m2 directory? The server service is run by Local System, so is that Default User? Or rather is it some other directory? I'll play around. Thanks for the lead!

0
Avatar
Permanently deleted user

To my experience the home directory for the SYSTEM user is c:\. Usually we recommend to confgure TeamCity services to be executed under some non default user account. This helps to avoid any problems finding user home.

0
Avatar
Permanently deleted user

Grazzie. I'll play around and see what I see. However, since the Build Agent and Build Server are the same box, it seems to me that one of the previous home directory locations I put the file in should have resulted in the problem being resolve.

0
Avatar
Permanently deleted user

I created a user called teamcity and set both the web service and build agent to run as said user (and gave them full ownership to the teamcity, maven, and deploy directories), and while everything else works, it still cannot find the parent POM. Is it enough to have the parent POM in my local repo or does the process by which the parent POM is discovered require me to list my own repository as a remote repo?

0
Avatar
Permanently deleted user

Well, to me this means that no one of the listed directories is really a home directory for the SYSTEM account. You can locate it by finding the .BuildServer directory which is also created in the user home by default. If you decide to switch your TeamCity services to another user account don't forget to move .BuildServer directory to the new location.

0
Avatar
Permanently deleted user

The Teamcity service both run as user teamcity now. SYSTEM no longer has anything to do with it. None of the directories have changed. I just made sure that the new teamcity user has full permission on the directories. The point is that the teamcity user's home directory, C:\Document and Settings\teamcity\.m2\settings.xml now has the local repo pointing to my local repository and it still can't find the parent POM. Everything else is working fine.

0
Avatar
Permanently deleted user

Oh, and I don't have a .buildserver directory. My teamcity installation is divied up like so:

c:\teamcity
c:\teamcity\conf
c:\teamcity\server
c:\teamcity\build

The conf directory is I believe what you would call the .buildserver directory. I didn't like how you put the .buildserver directory in the Administrator's home directory upon installation. That didn't seem right. The server directory is the server installation. The build directory is the build agent.

0
Avatar
Permanently deleted user

I was probably wrong with .BuildServer directory in case of running it as a service. I don't use it that way so I have to check. Sorry.

The conf directory is only for TeamCity settings files. It doesn't contain any user data.

Generally, having all the project dependencies in the local repo should be enough. But TeamCity uses by default its own local repository in the TeamCity data directory. This path specified in settings.xml is simply ignored. So I would recommend you providing the full remote repo list in the settings.

0
Avatar
Permanently deleted user

It still doesn't work. Here is my settings file. As you suggested, I listed my local repository as a remote repository (/repo on localhost contains all my published artifacts). What logs can I send you?

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

   <localRepository>c:\maven\repository</localRepository>
   <servers>
       <server>
           <id>maven.lostcreations.com-releases-private</id>
           <username>vsi</username>
           <password>vsi</password>
       </server>
   </servers>
   <profiles>
       <profile>
           <id>default</id>
           <repositories>
               <repository>
                   <id>localhost</id>
                   <name>localhost</id>
                   <releases>
                       <enabled>true</enabled>
                       <updatePolicy>never</updatePolicy>
                       <checksumPolicy>fail</checksumPolicy>
                   </releases>
                   <snapshots>
                       <enabled>true</enabled>
                       <updatePolicy>always</updatePolicy>
                       <checksumPolicy>fail</checksumPolicy>
                   </snapshots>
                   <url>http://127.0.0.1/repo/</url>
               </repository>
               <repository>
                   <id>maven.lostcreations.com-releases</id>
                   <name>maven.lostcreations.com-releases</name>
                   <releases>
                       <enabled>true</enabled>
                       <updatePolicy>never</updatePolicy>
                       <checksumPolicy>fail</checksumPolicy>
                   </releases>
                   <snapshots>
                       <enabled>false</enabled>
                   </snapshots>
                   <url>http://maven.lostcreations.com/releases/</url>
                   <layout>default</layout>
               </repository>
               <repository>
                   <id>maven.lostcreations.com-snapshots</id>
                   <name>maven.lostcreations.com-snapshots</name>
                   <snapshots>
                       <enabled>true</enabled>
                       <updatePolicy>always</updatePolicy>
                       <checksumPolicy>fail</checksumPolicy>
                   </snapshots>
                   <releases>
                       <enabled>false</enabled>
                   </releases>
                   <url>http://maven.lostcreations.com/snapshots/</url>
                   <layout>default</layout>
               </repository>
               <repository>
                   <id>maven.lostcreations.com-releases-private</id>
                   <name>maven.lostcreations.com-releases-private</name>
                   <releases>
                       <enabled>false</enabled>
                       <updatePolicy>never</updatePolicy>
                       <checksumPolicy>fail</checksumPolicy>
                   </releases>
                   <snapshots>
                       <enabled>false</enabled>
                   </snapshots>
                   <url>http://maven.lostcreations.com/releases-private/</url>
                   <layout>default</layout>
               </repository>
           </repositories>
           <pluginRepositories>
               <pluginRepository>
                   <id>maven.lostcreations.com-releases</id>
                   <name>maven.lostcreations.com-releases</name>
                   <releases>
                       <enabled>true</enabled>
                       <updatePolicy>never</updatePolicy>
                       <checksumPolicy>fail</checksumPolicy>
                   </releases>
                   <snapshots>
                       <enabled>false</enabled>
                   </snapshots>
                   <url>http://maven.lostcreations.com/releases/</url>
                   <layout>default</layout>
               </pluginRepository>
               <pluginRepository>
                   <id>maven.lostcreations.com-snapshots</id>
                   <name>maven.lostcreations.com-snapshots</name>
                   <snapshots>
                       <enabled>true</enabled>
                       <updatePolicy>always</updatePolicy>
                       <checksumPolicy>fail</checksumPolicy>
                   </snapshots>
                   <releases>
                       <enabled>false</enabled>
                   </releases>
                   <url>http://maven.lostcreations.com/snapshots/</url>
                   <layout>default</layout>
               </pluginRepository>
               <pluginRepository>
                   <id>maven.lostcreations.com-releases-private</id>
                   <name>maven.lostcreations.com-releases-private</name>
                   <releases>
                       <enabled>false</enabled>
                       <updatePolicy>never</updatePolicy>
                       <checksumPolicy>fail</checksumPolicy>
                   </releases>
                   <snapshots>
                       <enabled>false</enabled>
                   </snapshots>
                   <url>http://maven.lostcreations.com/releases-private/</url>
                   <layout>default</layout>
               </pluginRepository>
           </pluginRepositories>
       </profile>
   </profiles>
   <activeProfiles>
       <activeProfile>default</activeProfile>
   </activeProfiles>

</settings>

0
Avatar
Permanently deleted user

Could you please tell me at which remote repository of those listed your parent poms are located?

0
Avatar
Permanently deleted user

localhost has all of my poms, including the parents. FYI - When I click on a root POM (one that has no parent), it displays it's Maven info just fine.

0
Avatar
Permanently deleted user

If the localost is the only source of your parent pom dependencies, this won't work unless you have set up a repository manager with http access (or at least a properly configured http server) on your local machine.
You may try using an url like file://C:/repo/ instead of http://127.0.0.1/repo.

Anyway, my suggestion is to deploy your parent poms into one of your corporate repositories and list it in the settings or the project pom.

If for some reason you're unable to deploy your dependencies you can put them into the TeamCity own local repo I mentioned in one of the previous posts. It's located at <TeamCity data directory>/system/pluginData/maven/repository.
<TeamCity data directory> location is configured during TeamCity installation. I can guess that it's not default in your case.

0
Avatar
Permanently deleted user

I apologize for the confusion. As I mentioned earlier, I *do* have IIS configured on port 80 (TeamCity is on 8080) to point to the local repository for other developers to use. So http://127.0.0.1/repo is a perfectly valid URL. And I use the wagon plug-in to publish nightlies to http://127.0.0.1/nightly FWIW.

0
Avatar
Permanently deleted user

FWIW, I just got it working by using file://c:/inetpub/wwwroot/repo as the URL to the remote repo "localhost". "http://127.0.0.1/repo" didn't work. Even though I can get to it in a browser on the same host and others use the same URL to access the machine remotely (with the host name obviously). Interesting. I wonder if it has to do with the protocol being used to access the repo. I bet that HTTP causes the files to be encoded with a byte order mark at the beginning of the file causing the Java errors I saw.

Thank you for your help!

0
Avatar
Permanently deleted user

Oh, sorry for missing that. Then it's definitely a valid configuration despite the problems with host naming.

0
Avatar
Permanently deleted user

BTW I wonder if the url with the full host name is working. It's an interesting problem

0
Avatar
Permanently deleted user

I suppose I could try it and see, but now that it's working I'm hesitant to change things. Let me check real quick to see if I can break it my commenting out the repo. If I can't then that means there are caching issues at work and I don't care to keep bouncing the services to reload the new settings file (not that I was convinced I had to do this before, but I was playing safe).

0
Avatar
Permanently deleted user

I broke it by putting google.com for the repo URL and it can still recollect the data. It must have the POM cached in its own repo now. Once we're past this sprint I'll try reproducing the steps to cause the breakage. I'm just glad it's working. Thanks again for all the help. And now it's more straight-forward anyway since I removed the default Maven directory and settings file from all of my build configurations and replaced the former with M2_HOME in the system's environment variables and the latter is discovered via the new teamcity user's home directory.

0
Avatar
Permanently deleted user

OK. Anyway I'm glad it works somehow :)

0

Please sign in to leave a comment.