Friday, February 15, 2013

Maven Build Failed : Cannot Find Symbol

Getting the following exception when building my TempProject Project through Maven.
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.540s
[INFO] Finished at: Fri Feb 15 16:00:09 CST 2013
[INFO] Final Memory: 28M/205M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project temp-project: Compilation failure: Compilation failure:
[ERROR] \temp-project\src\main\java\com\temp.webapp\TestHandler.java:[18,29] cannot find symbol
[ERROR] symbol  : class TestService
[ERROR] location: package com.test.services

Although I have correctly added the artifact to dependencies section in the pom file as follows.

 <dependency>
            <groupId>com.test.service</groupId>
            <artifactId>testservice</artifactId>
            <version>1.27-SNAPSHOT</version>
</dependency>


Analysis:
This error usually comes when the jar with specified version is not available in the central or local maven repository. I rebuilt the parent testservice with snapshot version 1.27-SNAPSHOT.
And then tried to build my dependent temp-project again, I was able to build it successfully.

Be careful while building snapshot versions, because Maven might try to refer it in central repository and fail. in such cases you can try running the build in offline mode to see if it works.

No comments:

Post a Comment