8

I get errors like the following in Eclipse using Maven:

Missing artifact org.eclipse:swt:jar:3.7.
Project 'davmail' is missing required library: '/home/buzz-dee/.m2/repository/org/eclipse/swt/3.7.0/swt-3.7.0.jar'

Maven missing libraries error

Most libraries are found as you can see in the above image, but some not. But the files are in the right place.:

ls ~/.m2/repository/org/eclipse/swt/3.7.0/
swt-3.7.0.jar.lastUpdated  swt-3.7.0.pom.lastUpdated

This is a partial pom.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>
<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>davmail</groupId>
    <artifactId>davmail</artifactId>
    <packaging>jar</packaging>
    <version>4.6.1</version>
    <name>DavMail POP/IMAP/SMTP/Caldav/Carddav/LDAP Exchange Gateway</name>
    <organization>
        <name>Mickaël Guessant</name>
    </organization>
    <repositories>
        <repository>
            <id>central</id>
            <name>Maven Repository Switchboard</name>
            <layout>default</layout>
            <url>http://repo1.maven.org/maven2</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>xwiki</id>
            <layout>default</layout>
            <url>http://maven.xwiki.org/externals</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.jackrabbit</groupId>
            <artifactId>jackrabbit-webdav</artifactId>
            <version>2.4.3</version>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.jackrabbit</groupId>
                    <artifactId>jackrabbit-jcr-commons</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>xml-apis</groupId>
                    <artifactId>xml-apis</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.3.1</version>
        </dependency>
        <dependency>
            <groupId>commons-httpclient</groupId>
            <artifactId>commons-httpclient</artifactId>
            <version>3.1</version>
        </dependency>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.3</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.16</version>
            <exclusions>
                <exclusion>
                    <groupId>javax.jms</groupId>
                    <artifactId>jms</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.jdmk</groupId>
                    <artifactId>jmxtools</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.jmx</groupId>
                    <artifactId>jmxri</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4.3</version>
        </dependency>
        <dependency>
            <groupId>javax.activation</groupId>
            <artifactId>activation</artifactId>
            <version>1.1.1</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse</groupId>
            <artifactId>swt</artifactId>
            <version>3.7.0</version>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.4</version>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>net.sourceforge.htmlcleaner</groupId>
            <artifactId>htmlcleaner</artifactId>
            <version>2.2</version>
        </dependency>
        <!-- included in Java 1.6, needed with Java 1.5 -->
        <dependency>
            <groupId>org.codehaus.woodstox</groupId>
            <artifactId>woodstox-core-asl</artifactId>
            <version>4.1.2</version>
        </dependency>
        <dependency>
            <groupId>org.samba.jcifs</groupId>
            <artifactId>jcifs</artifactId>
            <version>1.3.14</version>
        </dependency>
        <dependency>
            <groupId>net.freeutils.charset</groupId>
            <artifactId>jcharset</artifactId>
            <version>1.3</version>
        </dependency>
        <dependency>
            <groupId>org.boris.winrun4j</groupId>
            <artifactId>winrun4j</artifactId>
            <version>0.4.5</version>
        </dependency>
    </dependencies>
    <pluginRepositories>
        <pluginRepository>
            <id>apache.snapshots</id>
            <url>http://repository.apache.org/snapshots</url>
            <releases>
                <enabled>false</enabled>
            </releases>
        </pluginRepository>
    </pluginRepositories>
    <build>
        <sourceDirectory>src/java</sourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.5</source>
                    <target>1.5</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <version>2.2</version>
            </plugin>
        </plugins>
    </build>
</project>

What could be wrong?

durron597
  • 31,968
  • 17
  • 99
  • 158
BuZZ-dEE
  • 6,075
  • 12
  • 66
  • 96
  • 1
    The `.lastupdated` files are not real artifacts. It maven last looked for them at that timestamp and didn't find them. The file sizes should be a giveaway. See: http://stackoverflow.com/questions/2529218/maven-downloads-have-lastupdated-as-extension – RaGe Apr 30 '15 at 21:24
  • Thanks, I overlooked the .`lastUpdated` in the file name `swt-3.7.0.jar.lastUpdated`. I have that files already in the project libs folder. Is the a Maven command too copy that files to the Maven repository folder? – BuZZ-dEE Apr 30 '15 at 21:49
  • If you are connected to the internet, just run maven with the -U flag, it force download the dependencies. – RaGe Apr 30 '15 at 21:52
  • I ran `mvn -U clean compile install`, but then i get the error: `[ERROR] Failed to execute goal on project davmail: Could not resolve dependencies for project davmail:davmail:jar:4.6.1: Could not find artifact org.eclipse:swt:jar:3.7.0 in central (http://repo1.maven.org/maven2) -> [Help 1]`. – BuZZ-dEE Apr 30 '15 at 22:04
  • 1
    As the guy below pointed out, swt:3.7 is not available in maven central. The davmail version you're using seems to have setup their dependencies wrong. Time to add more more exclusions to your pom I suppose. Apparently more people have issues with davmail transitive depenencies: http://sourceforge.net/p/davmail/mailman/davmail-users/thread/20130528152928.GH25136@gpm.stappers.nl/ – RaGe Apr 30 '15 at 22:11
  • this:http://davmail.sourceforge.net/dependencies.html says org.eclipse.swt is optional. You should try removing the whole dependency and see if it builds. – RaGe Apr 30 '15 at 22:17
  • I added successful `swt.jar` with `mvn install:install-file -DgroupId=org.eclipse -DartifactId=swt -Dversion=3.7.0 -Dpackaging=jar -Dfile=lib/swt-3.7-win32-x86.jar` as [stated there](http://stackoverflow.com/questions/29977916/eclipse-maven-project-is-missing-required-library-missing-artifact?noredirect=1#comment48076934_29977916). – BuZZ-dEE Apr 30 '15 at 22:36

2 Answers2

3

Disregard previous answer.

Maven central doesn't have version 3.7.0 for org.eclipse.swt. The latest version according to maven central is 3.3.0. You can see that in the link here. mvnrepository.com doesn't have it either.

You could try using the 3.3.0 version or you could try manually adding into your source folder, but, again, the latest version available on their website is 4.4.2

durron597
  • 31,968
  • 17
  • 99
  • 158
  • If I deleted the file `swt-3.7.0.jar.lastUpdated` and `swt-3.7.0.pom.lastUpdated`, I get them back, If I click "Update project". For the other files I manually copied to that folder and clicked on "Update project" which was working. – BuZZ-dEE Apr 30 '15 at 22:02
3

According to this DavMail page, org.eclipse:swt:jar:3.7.0 is an optional dependency. It isn't in mavenCentral, you could probably hunt it down from some other repository, but the simplest thing to do would be to remove that dependency from your pom and rebuild using -U

Alternatively, as discussed here, you can download the jar from here and install it to your local .m2 repo using the install command:

mvn install:install-file -DgroupId=org.eclipse -DartifactId=swt -Dversion=3.7.0 -Dpackaging=jar -Dfile=lib/swt-3.7-win32-x86.jar

Please note though, that this is a temporary fix, that will have to be repeated on every machine you want to build this project on. That kinda defeats the point of offloading dependency management to a tool like Maven. I would still prefer removing swt as a dependency from your project if that works.

RaGe
  • 22,696
  • 11
  • 72
  • 104
  • The SWT jars are already in the checked out source code. It's not necessary to download them again. – BuZZ-dEE Apr 30 '15 at 23:29