0

I'm unable to import a set of libraries within a java project in Intellij. I'm using maven to resolve dependencies; the dependencies in the pom file are as follows:

pom.xml

...
<dependencies>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>17.0</version>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-all</artifactId>
            <version>4.0.21.Final</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.3.5</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.dataformat</groupId>
            <artifactId>jackson-dataformat-xml</artifactId>
            <version>2.3.5</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-jdk14</artifactId>
            <version>1.7.7</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.antlr</groupId>
            <artifactId>antlr4-maven-plugin</artifactId>
            <version>4.2.2</version>
        </dependency>
        <dependency>
            <groupId>org.fiware.kiara</groupId>
            <artifactId>kiaraparser</artifactId>
            <version>0.2.0</version>
        </dependency>
</dependencies>
...

They are successfully included in the class path. However, when I try to use them in the project:

import com.google.common.util.concurrent.ListenableFuture;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.GenericFutureListener;

the following errors are thrown:

Error:(20, 41) java: package com.google.common.util.concurrent does not exist
Error:(21, 32) java: package io.netty.util.concurrent does not exist
Error:(22, 32) java: package io.netty.util.concurrent does not exist
Error:(34, 81) java: cannot find symbol
  symbol: class ListenableFuture
Error:(34, 59) java: cannot find symbol
  symbol: class Future

The libraries are present in the class path:

dependencies

Why are they not included within the project upon build?

Edit #1:

The exact steps when importing the project in Intellij are shown bellow:

step 1 step 2 step 3 step 4 step 5 step 6 step 7 step 8

After doing a "File -> Invalidate Caches/Restart" and a "Reimport All Maven Projects" the errors persist. The log file contents created after these two operations are shown here.

Why aren't the dependencies being loaded?

Edit #2:

Following the suggestions mentioned here I now get an error of type "Module must not contain source root. The root already belongs to module":

dependencies 1 dependencies 2

Community
  • 1
  • 1
Sebi
  • 4,262
  • 13
  • 60
  • 116
  • Sometimes, Intellij has a problem when it is importing maven dependencies (you could check by looking at the idea.log) when that is the case I've been able to get past it by right clicking on the project and selecting Maven -> Reimport. Sometimes I'll need to do a File -> Invalidate Cache / Restart as well. – EGHM Oct 28 '15 at 00:58
  • I've tried doing an invalidate cache/restart and reimporting all dependencies but it didn't work – Sebi Oct 28 '15 at 12:11

1 Answers1

0

I've fixed it by opening the project directory; picking the third option in Intellij's menu:

Intellij menu

Sebi
  • 4,262
  • 13
  • 60
  • 116