title: Maven complains "cannot find symbol" during compile
body: <p>I am getting "cannot find symbol" whenever I compile my code .But when I do  a rebuild to my project and then compile it works.Dont know why this is happening I am assuming it is because of the import on BSLocal. </p>
  
  <pre><code>    "C:\Program Files\Java\jdk1.8.0_201\bin\java.exe" -Dmaven.multiModuleProjectDirectory=C:\Users\njayanthy\Desktop\WPS\BrowserStack "-Dmaven.home=C:\Program Files\JetBrains\IntelliJ IDEA 2018.2.2\plugins\maven\lib\maven3" "-Dclassworlds.conf=C:\Program Files\JetBrains\IntelliJ IDEA 2018.2.2\plugins\maven\lib\maven3\bin\m2.conf" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2018.2.2\lib\idea_rt.jar=65122:C:\Program Files\JetBrains\IntelliJ IDEA 2018.2.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA 2018.2.2\plugins\maven\lib\maven3\boot\plexus-classworlds-2.5.2.jar" org.codehaus.classworlds.Launcher -Didea.version=2018.2.4 clean compile package install
  [INFO] Scanning for projects...
  [INFO]                                                                         
  [INFO] ------------------------------------------------------------------------
  [INFO] Building BrowserStack 1.0-SNAPSHOT
  [INFO] ------------------------------------------------------------------------
  [INFO] 
  [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ BrowserStack ---
  [INFO] Deleting C:\Users\njayanthy\Desktop\WPS\BrowserStack\target
  [INFO] 
  [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ BrowserStack ---
  [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
  [INFO] Copying 0 resource
  [INFO] 
  [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ BrowserStack ---
  [INFO] Nothing to compile - all classes are up to date
  [INFO] 
  [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ BrowserStack ---
  [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
  [INFO] Copying 0 resource
  [INFO] 
  [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ BrowserStack ---
  [INFO] Nothing to compile - all classes are up to date
  [INFO] 
  [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ BrowserStack ---
  [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
  [INFO] Copying 1 resource
  [INFO] 
  [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ BrowserStack ---
  [INFO] Changes detected - recompiling the module!
  [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
  [INFO] Compiling 2 source files to C:\Users\njayanthy\Desktop\WPS\BrowserStack\target\test-classes
  [INFO] -------------------------------------------------------------
  [ERROR] COMPILATION ERROR : 
  [INFO] -------------------------------------------------------------
  [ERROR] /C:/Users/njayanthy/Desktop/WPS/BrowserStack/src/test/java/com/mtrustcompany/browserstack/TestBase.java:[29,31] cannot find symbol
    symbol: class BSLocal
  [ERROR] /C:/Users/njayanthy/Desktop/WPS/BrowserStack/src/test/java/com/mtrustcompany/browserstack/TestBase.java:[31,19] cannot find symbol
    symbol:   class BSLocal
    location: class com.mtrustcompany.browserstack.TestBase
  [ERROR] /C:/Users/njayanthy/Desktop/WPS/BrowserStack/src/test/java/com/mtrustcompany/browserstack/TestBase.java:[31,37] cannot find symbol
    symbol:   variable BSLocal
    location: class com.mtrustcompany.browserstack.TestBase
  [ERROR] /C:/Users/njayanthy/Desktop/WPS/BrowserStack/src/test/java/com/mtrustcompany/browserstack/TestBase.java:[38,28] cannot find symbol
    symbol: method getClass()
  [INFO] 4 errors 
  [INFO] -------------------------------------------------------------
  [INFO] ------------------------------------------------------------------------
  [INFO] BUILD FAILURE
  [INFO] ------------------------------------------------------------------------
  [INFO] Total time: 1.625 s
  [INFO] Finished at: 2019-04-24T09:45:19-05:00
  [INFO] Final Memory: 21M/538M
  [INFO] ------------------------------------------------------------------------
  [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (default-testCompile) on project BrowserStack: Compilation failure: Compilation failure:
  [ERROR] /C:/Users/njayanthy/Desktop/WPS/BrowserStack/src/test/java/com/mtrustcompany/browserstack/TestBase.java:[29,31] cannot find symbol
  [ERROR] symbol: class BSLocal
  [ERROR] /C:/Users/njayanthy/Desktop/WPS/BrowserStack/src/test/java/com/mtrustcompany/browserstack/TestBase.java:[31,19] cannot find symbol
  [ERROR] symbol:   class BSLocal
  [ERROR] location: class com.mtrustcompany.browserstack.TestBase
  [ERROR] /C:/Users/njayanthy/Desktop/WPS/BrowserStack/src/test/java/com/mtrustcompany/browserstack/TestBase.java:[31,37] cannot find symbol
  [ERROR] symbol:   variable BSLocal
  [ERROR] location: class com.mtrustcompany.browserstack.TestBase
  [ERROR] /C:/Users/njayanthy/Desktop/WPS/BrowserStack/src/test/java/com/mtrustcompany/browserstack/TestBase.java:[38,28] cannot find symbol
  [ERROR] symbol: method getClass()
  [ERROR] -&gt; [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
  </code></pre>
  
  <p>this is the TestBase.java class </p>
  
  <pre><code>package com.mtrustcompany.browserstack;
  
  import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.remote.CapabilityType;
  import org.openqa.selenium.remote.DesiredCapabilities;
  import org.openqa.selenium.remote.RemoteWebDriver;
  import org.testng.annotations.AfterSuite;
  import org.testng.annotations.AfterTest;
  import org.testng.annotations.DataProvider;
  
  import javax.activation.DataHandler;
  import javax.activation.DataSource;
  import javax.activation.FileDataSource;
  import javax.mail.*;
  import javax.mail.internet.InternetAddress;
  import javax.mail.internet.MimeBodyPart;
  import javax.mail.internet.MimeMessage;
  import javax.mail.internet.MimeMultipart;
  import java.lang.reflect.Method;
  import java.net.MalformedURLException;
  import java.net.URL;
  import java.rmi.UnexpectedException;
  import java.text.SimpleDateFormat;
  import java.util.Calendar;
  import java.util.Date;
  import java.util.Properties;
  
  
  public class TestBase extends BSLocal {
  
      public static BSLocal bsLocal = BSLocal.getInstance();
      static URL serverUrl;
  
      public WebDriver getWebDriver() {
          return webDriver.get();
      }
  
      String className = this.getClass().getSimpleName();
  
      static {
          try {
              ;
              serverUrl = new URL(String.format("http://%s:%s@%s/wd/hub", bsLocal.username, bsLocal.accessKey, bsLocal.server));
          } catch (MalformedURLException e) {
              e.printStackTrace();
          }
      }
  
      /**
       * ThreadLocal variable which contains the  {@link WebDriver} instance which is used to perform browser interactions with.
       */
      private ThreadLocal&lt;WebDriver&gt; webDriver = new ThreadLocal&lt;WebDriver&gt;();
  
      /**
       * DataProvider that explicitly sets the browser combinations to be used.
       *
       * @param testMethod
       * @return Two dimensional array of objects with browser, version, and platform information
       */
      @DataProvider(name = "browsers", parallel = true)
      public static Object[][] sauceBrowserDataProvider(Method testMethod) {
          return new Object[][]{
                  new Object[]{"firefox", "65.0", "Windows 10"},
                  new Object[]{"chrome", "70", "windows 10"},
  
          };
      }
  
      /**
       * @return the {@link WebDriver} for the current thread
       */
  
  
      protected void createDriver(String browser, String version, String os, String methodName)
              throws MalformedURLException, UnexpectedException {
          Calendar now = Calendar.getInstance();
          int year = now.get(Calendar.YEAR);
          int month = now.get(Calendar.MONTH) + 1; // Note: zero based!
          int day = now.get(Calendar.DAY_OF_MONTH);
          Calendar c = Calendar.getInstance();
          c.set(year, month - 1, day, 0, 0);
          SimpleDateFormat format = new SimpleDateFormat("MMM dd,yyyy  hh");
          DesiredCapabilities capabilities = new DesiredCapabilities();
          capabilities.setCapability("build", String.format("%s %s", className, format.format(c.getTime())));
          capabilities.setCapability(CapabilityType.BROWSER_NAME, browser);
          capabilities.setCapability(CapabilityType.VERSION, version);
          capabilities.setCapability("name", methodName);
          capabilities.setCapability("browserstack.local", "true");
  
          webDriver.set(new RemoteWebDriver(
                  serverUrl,
                  capabilities));
  
      }
  
  
      @AfterTest
      public void done() {
          bsLocal.stop();
      }
  
      @AfterSuite
      public void mailTestReport() {
  
          Properties props = new Properties();
          props.put("mail.smtp.host", "smtp.gmail.com");
          props.put("mail.smtp.socketFactory.port", "465");
          props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
          props.put("mail.smtp.auth", "true");
          props.put("mail.smtp.port", "465");
          Session session = Session.getDefaultInstance(props,
                  new javax.mail.Authenticator() {
                      protected PasswordAuthentication getPasswordAuthentication() {
                          return new PasswordAuthentication("", "");
                      }
                  });
  
          try {
  
              Message message = new MimeMessage(session);
              message.setFrom(new InternetAddress("jayanthymohit6@gmail.com"));
              message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(""));
              message.setSubject(String.format("%s %s", className, new Date()));
              BodyPart messageBodyPart1 = new MimeBodyPart();
              messageBodyPart1.setText("Test Results");
              MimeBodyPart messageBodyPart2 = new MimeBodyPart();
              String filename = "C:\\Users\\njayanthy\\Desktop\\WPS\\BrowserStack\\test-output\\emailable-report.html";
              DataSource source = new FileDataSource(filename);
              messageBodyPart2.setDataHandler(new DataHandler(source));
              messageBodyPart2.setFileName(filename);
              Multipart multipart = new MimeMultipart();
              multipart.addBodyPart(messageBodyPart2);
              multipart.addBodyPart(messageBodyPart1);
              message.setContent(multipart);
              Transport.send(message);
              System.out.println("=====Email Sent=====");
          } catch (MessagingException e) {
              throw new RuntimeException(e);
          }
      }
  
  }
  </code></pre>
  
  <p>I am not able to understand why this is happening , and what happens in the manual project build in the ide that runs the compile without any issues ?</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  </code></pre>
  
  <p>http://maven.apache.org/xsd/maven-4.0.0.xsd">
      4.0.0</p>
  
  <pre><code>&lt;groupId&gt;MTC&lt;/groupId&gt;
  &lt;artifactId&gt;BrowserStack&lt;/artifactId&gt;
  &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
  &lt;repositories&gt;
      &lt;repository&gt;
          &lt;id&gt;sonatype-nexus-snapshots&lt;/id&gt;
          &lt;url&gt;https://oss.sonatype.org/content/repositories/snapshots&lt;/url&gt;
      &lt;/repository&gt;
  &lt;/repositories&gt;
  &lt;pluginRepositories&gt;
      &lt;pluginRepository&gt;
          &lt;id&gt;sonatype-nexus-snapshots&lt;/id&gt;
          &lt;url&gt;https://oss.sonatype.org/content/repositories/snapshots&lt;/url&gt;
      &lt;/pluginRepository&gt;
  &lt;/pluginRepositories&gt;
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.browserstack&lt;/groupId&gt;
          &lt;artifactId&gt;automate-testassist&lt;/artifactId&gt;
          &lt;version&gt;1.0.0-SNAPSHOT&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;!-- https://mvnrepository.com/artifact/org.codehaus.groovy/groovy-all --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.codehaus.groovy&lt;/groupId&gt;
          &lt;artifactId&gt;groovy-all&lt;/artifactId&gt;
          &lt;version&gt;3.0.0-alpha-4&lt;/version&gt;
          &lt;type&gt;pom&lt;/type&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;com.browserstack&lt;/groupId&gt;
          &lt;artifactId&gt;browserstack-local-java&lt;/artifactId&gt;
          &lt;version&gt;0.3.0&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.hamcrest&lt;/groupId&gt;
          &lt;artifactId&gt;hamcrest-core&lt;/artifactId&gt;
          &lt;version&gt;1.3&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.testng&lt;/groupId&gt;
          &lt;artifactId&gt;testng&lt;/artifactId&gt;
          &lt;version&gt;6.14.3&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.seleniumhq.selenium&lt;/groupId&gt;
          &lt;artifactId&gt;selenium-java&lt;/artifactId&gt;
          &lt;version&gt;3.11.0&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.sun.mail&lt;/groupId&gt;
          &lt;artifactId&gt;javax.mail&lt;/artifactId&gt;
          &lt;version&gt;1.6.0&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;com.aventstack&lt;/groupId&gt;
          &lt;artifactId&gt;extentreports&lt;/artifactId&gt;
          &lt;version&gt;3.1.5&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;commons-lang&lt;/groupId&gt;
          &lt;artifactId&gt;commons-lang&lt;/artifactId&gt;
          &lt;version&gt;2.6&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.saucelabs&lt;/groupId&gt;
          &lt;artifactId&gt;sauce_testng&lt;/artifactId&gt;
          &lt;version&gt;2.1.23&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  
  &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
              &lt;version&gt;3.1&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;source&gt;1.8&lt;/source&gt;
                  &lt;target&gt;1.8&lt;/target&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.12.4&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;parallel&gt;methods&lt;/parallel&gt;
                  &lt;threadCount&gt;40&lt;/threadCount&gt;
                  &lt;suiteXmlFiles&gt;
                      &lt;suiteXmlFile&gt;testng.xml&lt;/suiteXmlFile&gt;
                  &lt;/suiteXmlFiles&gt;
                  &lt;redirectTestOutputToFile&gt;true&lt;/redirectTestOutputToFile&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;com.browserstack&lt;/groupId&gt;
              &lt;artifactId&gt;automate-maven-plugin&lt;/artifactId&gt;
              &lt;version&gt;1.0.0-SNAPSHOT&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;source&gt;1.8&lt;/source&gt;
                  &lt;target&gt;1.8&lt;/target&gt;
                  &lt;complianceLevel&gt;1.8&lt;/complianceLevel&gt;
              &lt;/configuration&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;test-compile&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p></p>