1
votes

I am trying to follow the 'Adding Unmanaged Dependencies to a Maven Project' article on Heroku to add a local JAR dependency to a java project. I keep on getting stuck at the Update Pom file section, where it tells me to add/update the repositories element. I added the example repository elements to my pom.xml file and when i try to push my code to heroku i receive the following error:

Failed to execute goal on project fuji: Could not resolve dependencies for project com.example.fuji:fuji:jar:1.0-SNAPSHOT: Could not find artifact com.example.tambora:Tambora:jar:0.0.1-SNAPSHOT in project.local

It seems that I named either the repository id or name element wrong but I can't figure out what they should be changed too. I am able to run this application locally without receiving any errors.

Heres my pom.xml file

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.example.fuji</groupId>
  <artifactId>fuji</artifactId>
  <version>1.0-SNAPSHOT</version>
  <name>Fuji</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>com.example.tambora</groupId>
      <artifactId>Tambora</artifactId>
      <version>0.0.1-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-core</artifactId>
        <version>7.0.22</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-logging-juli</artifactId>
        <version>7.0.22</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-jasper</artifactId>
        <version>7.0.22</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-jasper</artifactId>
        <version>7.0.22</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-jasper-el</artifactId>
        <version>7.0.22</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-jsp-api</artifactId>
        <version>7.0.22</version>
    </dependency>
  </dependencies>
  <build>
    <finalName>fuji</finalName>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>appassembler-maven-plugin</artifactId>
            <version>1.1.1</version>
            <configuration>
                <assembleDirectory>target</assembleDirectory>
                <programs>
                    <program>
                        <mainClass>launch.Main</mainClass>
                        <name>webapp</name>
                    </program>
                </programs>
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>assemble</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
  </build>
  <repositories>
    <!--other repositories if any-->
    <repository>
        <id>project.local</id>
        <name>project</name>
        <url>file:${project.basedir}/repo</url>
    </repository>
</repositories>
</project>
1
Without the pom.xml file it's hard to guess what's wrong.khmarbaise
I updated the original question with my pom.xml file.user1941911

1 Answers

2
votes

This is probably happening because com.example.tambora:Tambora:jar:0.0.1-SNAPSHOT is a SNAPSHOT, but SNAPSHOTs have not been enabled for your custom repository. According to Maven: The Complete Reference, this is required:

As a default setting, Maven will not check for SNAPSHOT releases on remote repositories. To depend on SNAPSHOT releases, users must explicitly enable the ability to download snapshots using a repository or pluginRepository element in the POM.

You should be able that like this:

<repository>
    <id>project.local</id>
    <name>project</name>
    <url>file:${project.basedir}/repo</url>
    <snapshots>
        <enabled>true</enabled>
    <checksumPolicy>fail</checksumPolicy>
  </snapshots>
</repository>

Also, when troubleshooting this locally, I would recommend deleting your ~/.m2/repo/com/example/tambora directory, because what's probably happening is that Maven is finding the JAR in your local repo instead of the one embedded in your project.