Richard
Richard

Reputation: 423

Maven "cannot find symbol" error on Linux but not Windows

My problem is a similar to that at: maven compilation failure But no solutions there have worked.

I have two maven projects: A is a dependency of B. I can successfully compile, test, package, and install A on both Windows 7 (my development machine) and Linux (AWS EC2 instance). I can also compile, test, package, and install B on Windows 7. When I try to compile B on Linux, however, maven presents a "cannot find symbol" error:

    # mvn clean package install                                                                                                                 
    [INFO] Scanning for projects...
    [INFO]                                                                         
    [INFO] ------------------------------------------------------------------------
    [INFO] Building xxxxx-api Maven Webapp 1.0-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO] 
    [INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ xxxxx-api ---
    [INFO] Deleting /secure-mnt/xxxxx-api/target
    [INFO] 
    [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ xxxxx-api ---
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] Copying 5 resources
    [INFO] 
    [INFO] --- maven-compiler-plugin:3.0:compile (default-compile) @ xxxxx-api ---
    [INFO] Changes detected - recompiling the module!
    [INFO] Compiling 20 source files to /secure-mnt/xxxxx-api/target/classes
    [INFO] -------------------------------------------------------------
    [ERROR] COMPILATION ERROR : 
    [INFO] -------------------------------------------------------------
    [ERROR] /secure-mnt/xxxxx-api/src/main/java/com/company/util/Logging.java:[21,13] cannot find symbol
      symbol: class CryptoLogging
    [ERROR] /secure-mnt/xxxxx-api/src/main/java/com/company/util/Logging.java:[32,39] cannot find symbol
      symbol:   method getLogger(java.lang.String)
      location: class com.company.util.Logging
    [INFO] 2 errors 
    .....                                                                                                              

I have identical versions of Java (1.7.0_25) and Maven (3.0.5) installed on both systems, and both are using the same source code versions from Git.

Running mvn dependency:list shows no warnings. The Project A jar is in the local m2 repository on the Linux server, and does have the classes and methods available.

It seems as though Maven is not making the Java compiler aware of the Project A jar on Linux, but I do not understand why. Could Maven be failing to specify the Java classpath correctly?

Does anyone have suggestions of things to try or test?

In case it is relevant:

# mvn -version                                                                                                                              
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 13:51:28+0000)
Maven home: /usr/local/apache-maven/apache-maven-3.0.5
Java version: 1.7.0_25, vendor: Oracle Corporation
Java home: /usr/java/jdk1.7.0_25/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.4.48-45.46.amzn1.x86_64", arch: "i386", family: "unix"

Since I am sure someone will ask to see the POM, here is the relevant portion for Project B. There is nothing special about the dependencies at all:

<dependencies>
<!-- For Project A. -->
<dependency>
  <groupId>com.company.projectA</groupId>
  <artifactId>company-projectA</artifactId>
  <version>1.0-SNAPSHOT</version>
</dependency>

<!-- For RESTful services. -->
<dependency>
    <groupId>com.google.code.gson</groupId>
    <artifactId>gson</artifactId>
    <version>2.2.2</version>
</dependency>

<!-- For testing. -->
<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>4.10</version>
  <scope>test</scope>
</dependency>
</dependencies>

Thanks greatly for any help.

Upvotes: 4

Views: 1681

Answers (1)

Richard
Richard

Reputation: 423

After further research, this turned out not to be a maven problem at all. Some files had incorrect UNIX permissions, which somehow resulted in the misleading error. After making sure all the working directories had been chown'd and chmod'd properly, the build worked.

Upvotes: 2

Related Questions