1

This Maven error has me completely stumped, so I could use some help. I have a project that declares an in-project repo like this:

<parent>
    <groupId>ca.gc.agr.common</groupId>
    <artifactId>drydock-parent</artifactId>
    <relativePath>../DryDockPOM/pom.xml</relativePath>
</parent>
<artifactId>CognosReportService</artifactId>
<packaging>jar</packaging>
<version>2.0</version>

<name>CognosReportService</name>

<!-- In Project repository  -->
<repositories>
    <repository>
        <id>in-project</id>
        <name>In Project Repo</name>
        <url>file://${project.basedir}/libs</url>
    </repository>
</repositories> 

<dependencies>
    ... stuff ...

    <dependency>
        <groupId>cognos-sdk</groupId>
        <artifactId>cognos-client</artifactId>
        <version>8.4.1</version>
    </dependency>

    <dependency>
        <groupId>cognos-sdk</groupId>
        <artifactId>cognos-axis</artifactId>
        <version>8.4.1</version>
    </dependency>

    ... stuff ...

</dependencies>

There is another project which uses this one like so:

<parent>
    <groupId>ca.gc.agr.common</groupId>
    <artifactId>common-web-parent</artifactId>
    <relativePath>../DryDockWebPOM/pom.xml</relativePath>
</parent>
<artifactId>CognosReportWeb</artifactId>
<packaging>jar</packaging>
<version>2.0</version>

<name>CognosReportWeb</name>

<dependencies>

    ... stuff ....

    <dependency>
        <groupId>ca.gc.agr.common</groupId>
        <artifactId>CognosReportService</artifactId>    
        <version>[1.0,)</version>
    </dependency>

    ... stuff ....

</dependencies>

If I go up to the parent project and do a mvn install from there, everything works. However, if I try to build CognosReportWeb by itself, I get this:

[ERROR] Failed to execute goal on project CognosReportWeb: Could not resolve dependencies for project ca.gc.agr.common:CognosReportWeb:jar:2.0: 
Failed to collect dependencies for [ca.gc.agr.common:CognosReportService:jar:[1.0,) (compile),
 ca.gc.agr.common:CommonWebJar:jar:[1.0,) (compile),
 org.apache.tomcat:tomcat-servlet-api:jar:7.0.16 (provided),
 javax.servlet.jsp:jsp-api:jar:2.2 (provided),
 javax.el:el-api:jar:2.2 (provided),
 org.glassfish.web:el-impl:jar:2.2 (provided),
 com.sun.faces:jsf-api:jar:2.1.7 (compile),
 com.sun.faces:jsf-impl:jar:2.1.7 (compile),
 org.apache.myfaces.tomahawk:tomahawk20:jar:1.1.10 (compile),
 org.richfaces:richfaces-bom:pom:4.2.0.Final (compile),
 org.richfaces.ui:richfaces-components-ui:jar:4.2.0.Final (compile),
 org.richfaces.core:richfaces-core-impl:jar:4.2.0.Final (compile),
 org.primefaces:primefaces:jar:5.0 (compile),
 org.springframework:spring-web:jar:4.0.0.RELEASE (compile),
 com.cybozu.labs:langdetect:jar:1.1-20120112 (compile),
 org.apache.myfaces.test:myfaces-test20:jar:1.0.7 (test),
 org.aspectj:aspectjweaver:jar:1.7.4 (compile),
 org.springframework:spring-context:jar:4.0.0.RELEASE (compile),
 org.springframework:spring-aspects:jar:4.0.0.RELEASE (compile),
 org.springframework:spring-tx:jar:4.0.0.RELEASE (compile),
 org.springframework:spring-test:jar:4.0.0.RELEASE (compile),
 org.springframework:spring-orm:jar:4.0.0.RELEASE (compile),
 org.springframework:spring-oxm:jar:4.0.0.RELEASE (compile),
 org.springframework:spring-jdbc:jar:4.0.0.RELEASE (compile),
 org.hibernate:hibernate-core:jar:4.1.7.Final (compile),
 commons-io:commons-io:jar:1.3.2 (compile),
 commons-lang:commons-lang:jar:2.4 (compile),
 commons-beanutils:commons-beanutils:jar:1.8.3 (compile),
 commons-validator:commons-validator:jar:1.3.1 (compile),
 log4j:log4j:jar:1.2.17 (compile),
 org.slf4j:slf4j-log4j12:jar:1.7.6 (compile),
 junit:junit:jar:4.11 (compile),
 junit-addons:junit-addons:jar:1.4 (compile),
 com.googlecode.log4jdbc:log4jdbc:jar:1.2 (compile),
 org.reflections:reflections:jar:0.9.9-RC1 (compile),
 oro:oro:jar:2.0.8 (compile),
 dbunit:dbunit:jar:2.1 (compile),
 com.h2database:h2:jar:1.3.175 (compile)]: 

 Failed to read artifact descriptor for org.aspectj:aspectjweaver:jar:1.8.0.M1: 
    Could not transfer artifact org.aspectj:aspectjweaver:pom:1.8.0.M1 from/to in-project (file://${project.basedir}/libs): 
        Repository path /libs does not exist, and cannot be created. -> [Help 1]

At a first glance, it seems like there is a problem with the org.aspectj:aspectjweaver:pom:1.8.0.M1, yet I if I comment out my own in-project repo in CognosReportService (and re-install), suddenly CognosReportWeb starts working.

I am really stumped. Am I doing something wrong?

Any ideas would be appreciated!

Val Blant
  • 1,664
  • 2
  • 24
  • 34

2 Answers2

0

Re "if I comment out my own in-project repo in CognosReportService (and re-install), suddenly CognosReportWeb starts working."

Your local Maven repo (default ~/.m2/repository or according to your settings.xmls) is used then and this is known to work reliably. So, it's not suddenly working, it's working by design. ;-)

The message at the end gives a crucial hint. Is org.aspectj:aspectjweaver:pom:1.8.0.M1 in file://${project.basedir}/libs?

What's the reason for using this extra repository?

Gerold Broser
  • 14,080
  • 5
  • 48
  • 107
  • The reason for using the extra repo is so that I can use some 3rd party jars as maven dependencies. I can't think of another way to make sure that people can run the Maven build after checking out my source, without having to manually insert these jars into their local repo. – Val Blant Oct 18 '14 at 05:28
  • @ValBlant [Why it's a bad idea to commit Java jar files into a repository](http://stackoverflow.com/questions/4649015/java-jar-files-into-a-repository-cvs-svn). – Gerold Broser Oct 18 '14 at 12:19
0

If the dependency is not available in Maven Central, and you want to make sure that anyone who checks out your code will be able to build your source without doing additional configuration or jar installs, then find any alternate public repository where the dependency is hosted.

and add it to your project just like how you have done(except for using local file based repo).

<repositories>
    <repository>
        <id>opencastproject</id>
        <url>http://repository.opencastproject.org/nexus/content/repositories/public/</url>
    </repository>
</repositories>

But in your case, similar or newer versions of the org.aspectj:aspectjweaver lib is available in Maven Central - http://central.maven.org/maven2/org/aspectj/aspectjweaver/, so probably you can just use

<dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjweaver</artifactId>
    <version>1.8.2</version>
</dependency>

instead?

coderplus
  • 5,793
  • 5
  • 34
  • 54
  • I don't think the problem has anything to do with aspectjweaver. The problematic version is requested by some other pom in Hibernate or Spring, so I always see that warning, yet the build succeeds. The jars I was trying to place into the in-project repo are not available in any public repo, b/c they are for a very obscure, proprietary system. I have worked around the problem by installing Nexus in our organization and placing the proprietary jars there, so now the build works. The errors I was getting with in-project repo still seem like a bug though. – Val Blant Oct 27 '14 at 01:24