6

I am developing application that uses Cassandra NoSQL database and I am adding web interface. I have 2 projects: cassandra-access (this project is DAL) and web (this project is web application).

Scenario is simple enaugh. Cassandra-access has dependencies on hector.jar which is not in maven repository. So I added this dependency to my local repository via mvn install:install-file and I list my repository in parent pom:

 <repositories>
      <repository>
        <id>loc</id>
        <url>file://${basedir}/../mvn-local-repository</url>
    </repository>
</repositories>

In Web projects pom I added dependency on Cassandra-access. But when i start the Web application with hello world read from database I am getting classNotFound exception as if the hector.jar isn't on class path. When I write mvn clean install the resulting war of web project doesn't include hector.jar in WEB-INF/lib. That further confirms my theory.

How to achieve that war get's all the transitive dependcies? I thought that all dependencies that are in scope compile (which is default) will get copied.

Web projects pom:

  <dependency>
      <groupId>net.product</groupId>
      <artifactId>cassandra-access</artifactId>
      <version>1.0-SNAPSHOT</version>
  </dependency>

Cassandra-access pom:

 <dependency>
   <groupId>me.prettyprint</groupId>
   <artifactId>hector</artifactId>
   <version>0.7.0</version>
 </dependency>
1
  • I have found that above text works as well. I just had WARNINGS in POM which causes maven to NOT INCLUDE TRANSITIVE DEPENDENCIES AT ALL. The best way to debug such a situation is using mvn dependency:tree -X Mar 30, 2011 at 8:49

1 Answer 1

1

It maybe not the optimal solution but it works for me: put the hector jar in the lib directory of the cassandra access. add to the cassandra-access pom:

<dependency>    
    <groupId>%HECTOR_JAR_GROUP_ID%</groupId>  
    <artifactId>%HECTOR_JAR_ARTIFACT_ID%</artifactId>  
    <version>%HECTOR_JAR_VERSION%</version>  
    <scope>system</scope>  
        <systemPath>${basedir}/lib/%HECTOR_JAR_NAME%</systemPath>  
</dependency>  

then add the following plugin:

<plugin>  
    <groupId>org.apache.maven.plugins</groupId>  
    <artifactId>maven-dependency-plugin</artifactId>  
    <executions>  
        <execution>  
            <id>copy-dependencies</id>
            <phase>package</phase>
            <goals>
                <goal>copy-dependencies</goal>
            </goals>
            <configuration>
                <outputDirectory>${project.build.directory}/lib</outputDirectory>
            </configuration>
        </execution>
    </executions>
</plugin>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.