I have a utility project, lets call it utility-library
that contains a class with the following structure.
public interface OuterInterfaceI {
public static class InnerClass {
// ... a couple of static and non static methods
}
}
Now when I try to do the following within the utility-library
, it compiles fine
OuterInterfaceI.InnerClass innerClassObject;
Now I need to use this in another project so I add the project's jar utility-library.jar
(built via mavent) to the build path of my project (lets call it my-application
). When I try to write the following code inside a class, it fails to compile.
import com.utility.commons.OuterInterfaceI;
public class SomeClass {
private static OuterInterfaceI.InnerClass myObject;
}
Compiler fails with the following error message
The type com.utility.commons.OuterInterfaceI.InnerClass cannot be resolved. It is indirectly referenced from required .class files.
I have made sure that the utility-library.jar
is on the classpath. Anything that I am missing ?
Update
I am using Eclipse Version: Mars.1 Release (4.5.1) and maven 3.3.3 with java 1.8.0_45. I thought that this may be a bug in eclipse, but I am getting compile time issue with the same class when I try to build from terminal as well
$ mvn clean test
[INFO] Scanning for projects...
[INFO]
.....................
.....................
[INFO] Compiling 90 source files to /home/msamirza/etilize_repo_folders/jdk8_migrations/...................
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/msamirza/etilize_repo_folders/jdk8_migrations/inQuire/inQuireMerchandising/merch-server-module/src/main/java/com..... :[20,32] error: cannot access InnerClass
[ERROR] class file for com.utility.commons.OuterInterfaceI$InnerClass not found
/home/msamirza/etilize_repo_folders/jdk8_migrations/inQuire/inQuireMerchandising/merch-server-module/src/main/java/com/.....:[25,38] error: cannot find symbol
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.182 s
[INFO] Finished at: 2016-07-21T10:37:57+05:00
[INFO] Final Memory: 19M/226M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project inQuire-Merchandising-Server: Compilation failure: Compilation failure:
[ERROR] /home/msamirza/etilize_repo_folders/jdk8_migrations/inQuire/inQuireMerchandising/merch-server-module/src/main/java/com/........:[20,32] error: cannot access InnerClass
[ERROR] class file for com.utility.commons.OuterInterfaceI$InnerClass not found
[ERROR] /home/msamirza/etilize_repo_folders/jdk8_migrations/inQuire/inQuireMerchandising/merch-server-module/src/main/java/com/........:[25,38] error: cannot find symbol
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException