Maven java compile error can not access CommonClassA

user2210293 picture user2210293 · Aug 15, 2013 · Viewed 17.4k times · Source

Background:

  • I am developing Maven multi module project.
  • One of the module is common module needed by other all modules.
  • This module contain CommonClassA.java.
  • common module is properly compiled.
  • It is installed into maven local repository properly.
  • One of the class(Billtype.java) in other module (EmployeeBilling) refers this class(CommonClassA.java).
  • Maven Dependency for common module is properly specified in pom.xml of EmployeeBilling module.

Problem:

While compiling EmployeeBilling module it throws

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project EmployeeBilling: Compilation failure
[ERROR] \MyWorkspace\Biz\EmployeeBilling\src\main\java\com\employee\Billtype.java:[79,19] error: cannot access CommonClassA
[ERROR] -> [Help 1]**

Supporting details:

  • dependency defined in EmployeeBilling> pom.xml:

  • Other classes from common module seems accessible as no error observed

  • There are no other errors like Class not found/file not found.
  • The class CommonCLassA implements Serializable
  • Same error occurs from Eclipse as well as commond line
  • I am using M2E plugin

Tools:

  • jdk1.7.0_02
  • OS: Windows 7
  • Eclipse JUNO and apache-maven-3.1.0

Thanks in advance!

Answer

Lokesh picture Lokesh · Aug 15, 2013

If project builds properly using eclipse compiler then it should work with Maven.

Few things to check if its not working with maven:

  1. Manually check in repository that jar is installed properly and it contains your class file.
  2. Try to build project using locally installed Maven instead of maven in eclipse.
  3. Set -DskipTest=true while installing your jar, as it can cause issues at times.

If these steps don't work then show us your pom.