Many "cannot find symbol" errors building with Maven & Eclipse

Application Name: Openmrs-core-master from git Version Number: https://github.com/openmrs/openmrs-core Question: Hey while i am trying to maven install the Openmrs project imported from git in Eclipse . The console ends of with following error. Can i get any suggestion to fix the problem? Hoping for quick response!!

[INFO] Scanning for projects...
[INFO] β€”----------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] OpenMRS
[INFO] openmrs-tools
[INFO] openmrs-test
[INFO] openmrs-api
[INFO] openmrs-web
[INFO] openmrs-webapp
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]                                                                        
[INFO] β€”----------------------------------------------------------------------
[INFO] Building OpenMRS 2.1.0-SNAPSHOT
[INFO] β€”----------------------------------------------------------------------
[INFO]
[INFO] β€”- buildnumber-maven-plugin:1.1:create (default) @ openmrs β€”-
[INFO] Checking for local modifications: skipped.
[INFO] Updating project files from SCM: skipped.
[INFO] ShortRevision tag detected. The value is '6'.
[INFO] Executing: cmd.exe /X /C "git rev-parse β€”verify β€”short=6 HEAD"
[INFO] Working directory: C:\openmrs\luna\openmrs-core-master
[INFO] Storing buildNumber: 0 at timestamp: 1457154472891
[INFO] ShortRevision tag detected. The value is '6'.
[INFO] Executing: cmd.exe /X /C "git rev-parse β€”verify β€”short=6 HEAD"
[INFO] Working directory: C:\openmrs\luna\openmrs-core-master
[INFO] Storing buildScmBranch: UNKNOWN_BRANCH
[INFO]
[INFO] β€”- build-helper-maven-plugin:1.5:parse-version (parse-version) @ openmrs β€”-
[INFO]
[INFO] β€”- maven-jar-plugin:2.3.2:test-jar (default) @ openmrs β€”-
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: C:\openmrs\luna\openmrs-core-master\target\openmrs-2.1.0-SNAPSHOT-tests.jar
[INFO]
[INFO] β€”- license-maven-plugin:2.6:check (default) @ openmrs β€”-
[INFO] Checking licenses...
[INFO]
[INFO] β€”- maven-install-plugin:2.4:install (default-install) @ openmrs β€”-
[INFO] Installing C:\openmrs\luna\openmrs-core-master\pom.xml to C:\Users\Niraj\.m2\repository\org\openmrs\openmrs\2.1.0-SNAPSHOT\openmrs-2.1.0-SNAPSHOT.pom
[INFO] Installing C:\openmrs\luna\openmrs-core-master\target\openmrs-2.1.0-SNAPSHOT-tests.jar to C:\Users\Niraj\.m2\repository\org\openmrs\openmrs\2.1.0-SNAPSHOT\openmrs-2.1.0-SNAPSHOT-tests.jar
[INFO]                                                                        
[INFO] β€”----------------------------------------------------------------------
[INFO] Building openmrs-tools 2.1.0-SNAPSHOT
[INFO] β€”----------------------------------------------------------------------
[INFO]
[INFO] β€”- buildnumber-maven-plugin:1.1:create (default) @ openmrs-tools β€”-
[INFO]
[INFO] β€”- build-helper-maven-plugin:1.5:parse-version (parse-version) @ openmrs-tools β€”-
[INFO]
[INFO] β€”- maven-resources-plugin:2.4:resources (default-resources) @ openmrs-tools β€”-
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 7 resources
[INFO]
[INFO] β€”- maven-compiler-plugin:2.1:compile (default-compile) @ openmrs-tools β€”-
[INFO] Compiling 1 source file to C:\openmrs\luna\openmrs-core-master\tools\target\classes
[INFO]
[INFO] β€”- maven-resources-plugin:2.4:testResources (default-testResources) @ openmrs-tools β€”-
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\openmrs\luna\openmrs-core-master\tools\src\test\resources
[INFO]
[INFO] β€”- maven-compiler-plugin:2.1:testCompile (default-testCompile) @ openmrs-tools β€”-
[INFO] No sources to compile
[INFO]
[INFO] β€”- maven-surefire-plugin:2.18.1:test (default-test) @ openmrs-tools β€”-
[INFO] No tests to run.
[INFO]
[INFO] β€”- maven-jar-plugin:2.3.2:jar (default-jar) @ openmrs-tools β€”-
[INFO] Building jar: C:\openmrs\luna\openmrs-core-master\tools\target\openmrs-tools-2.1.0-SNAPSHOT.jar
[INFO]
[INFO] β€”- maven-jar-plugin:2.3.2:test-jar (default) @ openmrs-tools β€”-
[WARNING] JAR will be empty - no content was marked for inclusion!
 
Niranjan Acharya, [05.03.16 10:57]
[INFO] Building jar: C:\openmrs\luna\openmrs-core-master\tools\target\openmrs-tools-2.1.0-SNAPSHOT-tests.jar
[INFO]
[INFO] β€”- license-maven-plugin:2.6:check (default) @ openmrs-tools β€”-
[INFO] Checking licenses...
[INFO]
[INFO] β€”- maven-install-plugin:2.4:install (default-install) @ openmrs-tools β€”-
[INFO] Installing C:\openmrs\luna\openmrs-core-master\tools\target\openmrs-tools-2.1.0-SNAPSHOT.jar to C:\Users\Niraj\.m2\repository\org\openmrs\tools\openmrs-tools\2.1.0-SNAPSHOT\openmrs-tools-2.1.0-SNAPSHOT.jar
[INFO] Installing C:\openmrs\luna\openmrs-core-master\tools\pom.xml to C:\Users\Niraj\.m2\repository\org\openmrs\tools\openmrs-tools\2.1.0-SNAPSHOT\openmrs-tools-2.1.0-SNAPSHOT.pom
[INFO] Installing C:\openmrs\luna\openmrs-core-master\tools\target\openmrs-tools-2.1.0-SNAPSHOT-tests.jar to C:\Users\Niraj\.m2\repository\org\openmrs\tools\openmrs-tools\2.1.0-SNAPSHOT\openmrs-tools-2.1.0-SNAPSHOT-tests.jar
[INFO]                                                                        
[INFO] β€”----------------------------------------------------------------------
[INFO] Building openmrs-test 2.1.0-SNAPSHOT
[INFO] β€”----------------------------------------------------------------------
[INFO]
[INFO] β€”- buildnumber-maven-plugin:1.1:create (default) @ openmrs-test β€”-
[INFO]
[INFO] β€”- build-helper-maven-plugin:1.5:parse-version (parse-version) @ openmrs-test β€”-
[INFO]
[INFO] β€”- maven-jar-plugin:2.3.2:test-jar (default) @ openmrs-test β€”-
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: C:\openmrs\luna\openmrs-core-master\test\target\openmrs-test-2.1.0-SNAPSHOT-tests.jar
[INFO]
[INFO] β€”- license-maven-plugin:2.6:check (default) @ openmrs-test β€”-
[INFO] Checking licenses...
[INFO]
[INFO] β€”- maven-install-plugin:2.4:install (default-install) @ openmrs-test β€”-
[INFO] Installing C:\openmrs\luna\openmrs-core-master\test\pom.xml to C:\Users\Niraj\.m2\repository\org\openmrs\test\openmrs-test\2.1.0-SNAPSHOT\openmrs-test-2.1.0-SNAPSHOT.pom
[INFO] Installing C:\openmrs\luna\openmrs-core-master\test\target\openmrs-test-2.1.0-SNAPSHOT-tests.jar to C:\Users\Niraj\.m2\repository\org\openmrs\test\openmrs-test\2.1.0-SNAPSHOT\openmrs-test-2.1.0-SNAPSHOT-tests.jar
[INFO]                                                                        
[INFO] β€”----------------------------------------------------------------------
[INFO] Building openmrs-api 2.1.0-SNAPSHOT
[INFO] β€”----------------------------------------------------------------------
[INFO]
[INFO] β€”- buildnumber-maven-plugin:1.1:create (default) @ openmrs-api β€”-
[INFO]
[INFO] β€”- build-helper-maven-plugin:1.5:parse-version (parse-version) @ openmrs-api β€”-
[INFO]
[INFO] β€”- maven-java-formatter-plugin:0.3:format (default) @ openmrs-api β€”-
[INFO] Using 'UTF-8' encoding to format source files.
[INFO] Number of files to be formatted: 950
[INFO] Successfully formatted: 0 file(s)
[INFO] Fail to format        : 0 file(s)
[INFO] Skipped               : 950 file(s)
[INFO] Approximate time taken: 14s
[INFO]
[INFO] β€”- maven-resources-plugin:2.4:resources (default-resources) @ openmrs-api β€”-
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 127 resources
[INFO]
[INFO] β€”- maven-compiler-plugin:2.1:compile (default-compile) @ openmrs-api β€”-
[INFO] Compiling 662 source files to C:\openmrs\luna\openmrs-core-master\api\target\classes
[INFO] β€”---------------------------------------------------------β€”
[ERROR] COMPILATION ERROR :
[INFO] β€”---------------------------------------------------------β€”
[ERROR] \openmrs\luna\openmrs-core-master\api\src\main\java\org\openmrs\util\DateUtil.java:[12,16] package java.time does not exist
 
[ERROR] \openmrs\luna\openmrs-core-master\api\src\main\java\org\openmrs\util\DateUtil.java:[13,25] package java.time.temporal does not exist
 
[ERROR] \openmrs\luna\openmrs-core-master\api\src\main\java\org\openmrs\util\MemoryLeakUtil.java:[18,23] sun.net.www.http.KeepAliveCache is Sun proprietary API and may be removed in a future release
 
Niranjan Acharya, [05.03.16 10:57]
[ERROR] \openmrs\luna\openmrs-core-master\api\src\main\java\org\openmrs\util\DateUtil.java:[27,2] cannot find symbol
symbol  : class Instant
location: class org.openmrs.util.DateUtil
 
[ERROR] \openmrs\luna\openmrs-core-master\api\src\main\java\org\openmrs\util\DateUtil.java:[27,49] cannot find symbol
symbol  : variable ChronoUnit
location: class org.openmrs.util.DateUtil
 
[ERROR] \openmrs\luna\openmrs-core-master\api\src\main\java\org\openmrs\util\DateUtil.java:[27,24] cannot find symbol
symbol  : method toInstant()
location: class java.util.Date
 
[ERROR] \openmrs\luna\openmrs-core-master\api\src\main\java\org\openmrs\util\MemoryLeakUtil.java:[67,32] sun.net.www.http.KeepAliveCache is Sun proprietary API and may be removed in a future release
 
[INFO] 7 errors
[INFO] β€”---------------------------------------------------------β€”
[INFO] β€”----------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] OpenMRS ........................................... SUCCESS [  4.189 s]
[INFO] openmrs-tools ..................................... SUCCESS [  2.968 s]
[INFO] openmrs-test ...................................... SUCCESS [  0.989 s]
[INFO] openmrs-api ....................................... FAILURE [ 28.205 s]
[INFO] openmrs-web ....................................... SKIPPED
[INFO] openmrs-webapp .................................... SKIPPED
[INFO] β€”----------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] β€”----------------------------------------------------------------------
[INFO] Total time: 36.714 s
[INFO] Finished at: 2016-03-05T10:53:27+05:45
[INFO] Final Memory: 33M/210M
[INFO] β€”----------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.1:compile (default-compile) on project openmrs-api: Compilation failure: Compilation failure:
[ERROR] \openmrs\luna\openmrs-core-master\api\src\main\java\org\openmrs\util\DateUtil.java:[12,16] package java.time does not exist
[ERROR]
[ERROR] \openmrs\luna\openmrs-core-master\api\src\main\java\org\openmrs\util\DateUtil.java:[13,25] package java.time.temporal does not exist
[ERROR]
[ERROR] \openmrs\luna\openmrs-core-master\api\src\main\java\org\openmrs\util\MemoryLeakUtil.java:[18,23] sun.net.www.http.KeepAliveCache is Sun proprietary API and may be removed in a future release
[ERROR]
[ERROR] \openmrs\luna\openmrs-core-master\api\src\main\java\org\openmrs\util\DateUtil.java:[27,2] cannot find symbol
[ERROR] symbol  : class Instant
[ERROR] location: class org.openmrs.util.DateUtil
[ERROR]
[ERROR] \openmrs\luna\openmrs-core-master\api\src\main\java\org\openmrs\util\DateUtil.java:[27,49] cannot find symbol
[ERROR] symbol  : variable ChronoUnit
[ERROR] location: class org.openmrs.util.DateUtil
[ERROR]
[ERROR] \openmrs\luna\openmrs-core-master\api\src\main\java\org\openmrs\util\DateUtil.java:[27,24] cannot find symbol
[ERROR] symbol  : method toInstant()
[ERROR] location: class java.util.Date
[ERROR]
[ERROR] \openmrs\luna\openmrs-core-master\api\src\main\java\org\openmrs\util\MemoryLeakUtil.java:[67,32] sun.net.www.http.KeepAliveCache is Sun proprietary API and may be removed in a future release
[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
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :openmrs-api

hi did you get this solved? @niraj

you can try to clear your .m2/Repository folder and try to build again

1 Like

thanks let me first dive in for that before i make a thread on talk

The β€œCannot find symbol” errors generally occur when you try to reference an undeclared variable in your code. A β€œCannot find symbol” error means that the compiler cannot do this. Your code appears to be referring to something that the compiler doesn’t understand.

When your code is compiled, the compiler needs to work out what each and every identifier in your code means. As the compiler is going through the code it will find something and know what to do with it or not. Your Cannot find symbol error relates to the identifiers and means that Java cannot figure out what the β€œsymbol” means.

The general causes for a Cannot find symbol error are things like:

  • Incorrect spelling.
  • Wrong case. Halo is different from halo.
  • Improper use of acceptable identifier values (letters, numbers, underscore, dollar sign), my-class is not the same as myclass.
  • No variable declaration or variable is outside of the scope you are referencing it in.