title: Java - A master URL must be set in your configuration
body: <p>I am trying to run some algorithm in apache Spark. I am getting 
  Java - A master URL must be set in your configuration error even if I set the  configuration.</p>
  
  <pre><code>SparkSession spark = SparkSession.builder().appName("Sp_LogistcRegression").config("spark.master", "local").getOrCreate();
  </code></pre>
  
  <p>This is the code I work with</p>
  
  <pre><code>import java.io.FileOutputStream;
  import java.io.IOException;
  import java.io.ObjectOutputStream;
  
  import org.apache.spark.SparkConf;
  import org.apache.spark.api.java.JavaSparkContext;
  import org.apache.spark.ml.classification.LogisticRegression;
  import org.apache.spark.ml.classification.LogisticRegressionModel;
  import org.apache.spark.sql.Dataset;
  import org.apache.spark.sql.Row;
  import org.apache.spark.sql.SparkSession;
  import org.apache.spark.mllib.util.MLUtils;
  
  public class Sp_LogistcRegression {
      public void trainLogisticregression(String path, String model_path) throws IOException {
          //SparkConf conf = new SparkConf().setAppName("Linear Regression Example");
  
  
      //  JavaSparkContext sc = new JavaSparkContext(conf);
          SparkSession spark = SparkSession.builder().appName("Sp_LogistcRegression").config("spark.master", "local").getOrCreate();
          Dataset&lt;Row&gt; training =  spark.read().option("header","true").csv(path);
           System.out.print(training.count());
  
          LogisticRegression lr = new LogisticRegression().setMaxIter(10).setRegParam(0.3);
  
          // Fit the model
          LogisticRegressionModel lrModel = lr.fit(training);
          lrModel.save(model_path);
  
  
  
          spark.close();
  
      }
  
  }
  </code></pre>
  
  <p>This is my test case:</p>
  
  <pre><code>import java.io.File;
  
  import org.junit.Test;
  
  public class Sp_LogistcRegressionTest {
      Sp_LogistcRegression spl =new Sp_LogistcRegression ();
  
  
  
  
      @Test
          public void test() {
  
              String filename = "datas/seg-large.csv";
              ClassLoader classLoader = getClass().getClassLoader();
              File file1 = new File(classLoader.getResource(filename).getFile());
              spl. trainLogisticregression( file1.getAbsolutePath(), "/tmp");
  
          }
  
      }
  </code></pre>
  
  <p>Why I am getting this error? I checked the solutions here 
  <a href="https://stackoverflow.com/questions/38008330/spark-error-a-master-url-must-be-set-in-your-configuration-when-submitting-a">Spark - Error &quot;A master URL must be set in your configuration&quot; when submitting an app</a>
  It does n´t work.
  Any clues ?</p>