title: security exception connecting spark master java
body: <p>I'm new at Spark. In my project, I set master url and app name as SparkConf object. </p>
  
  <p>here is my code </p>
  
  <pre><code>import org.apache.hadoop.conf.Configuration;
  import org.apache.spark.SparkConf;
  import org.apache.spark.api.java.JavaPairRDD;
  import org.apache.spark.api.java.JavaSparkContext;
  import org.bson.BSONObject;
  import com.mongodb.hadoop.MongoInputFormat;
  import com.mongodb.hadoop.MongoOutputFormat;
  
  public class SparkExample {
  
  @SuppressWarnings("resource")
  public static void main(String[] args) {
  
      Configuration conf = new Configuration();
  
      conf.set("mongo.job.input.format", "com.mongodb.hadoop.MongoInputFormat");
  
      conf.set("mongo.input.uri", "mongodb://192.168.1.149:27017/test.sns");
  
  
  
      JavaSparkContext sc = new JavaSparkContext(new SparkConf().setMaster("spark://localhost:7077").setAppName("vedat"));
  
      JavaPairRDD&lt;Object, BSONObject&gt; documents = sc.newAPIHadoopRDD(conf, MongoInputFormat.class, Object.class,
              BSONObject.class);
  
      Configuration outConfig = new Configuration();
  
      outConfig.set("mongo.job.output.format", "com.mongodb.hadoop.MongoOutputFormat");
  
      outConfig.set("mongo.output.uri", "mongodb://192.168.1.149:27017/test.ou");
  
      documents.saveAsNewAPIHadoopFile("file://44", Object.class, BSONObject.class, MongoOutputFormat.class,
              outConfig);
  
      Configuration bsonConf = new Configuration();
      bsonConf.set("mongo.job.output.format", "com.mongodb.hadoop.BSONFileOutputFormat");
  
      // documents.saveAsNewAPIHadoopFile("hds://localhost:8020/user/spark/demo",
      // Object.class, BSONObject.class,
      // BSONFileOutputformat.class, bsonConf);
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>When I run code I get this stack trace </p>
  
  <pre><code>ERROR spark.SparkContext: Error initializing SparkContext.
  java.lang.SecurityException: class "javax.servlet.FilterRegistration"'s      signer information does not match signer information of other classes in the same package
  at java.lang.ClassLoader.checkCerts(ClassLoader.java:952)
  at java.lang.ClassLoader.preDefineClass(ClassLoader.java:666)
  at java.lang.ClassLoader.defineClass(ClassLoader.java:794)
  at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
  at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
  at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
  at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
  at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
  at org.spark-project.jetty.servlet.ServletContextHandler.&lt;init&gt;(ServletContextHandler.java:136)
  at org.spark-project.jetty.servlet.ServletContextHandler.&lt;init&gt;(ServletContextHandler.java:129)
  at org.spark-project.jetty.servlet.ServletContextHandler.&lt;init&gt;(ServletContextHandler.java:98)
  at    
  org.apache.spark.ui.JettyUtils$.createServletHandler(JettyUtils.scala:108)
  
  at org.apache.spark.ui.JettyUtils$.createServletHandler(JettyUtils.scala:99)
  at org.apache.spark.ui.WebUI.attachPage(WebUI.scala:78)
  at org.apache.spark.ui.WebUI$$anonfun$attachTab$1.apply(WebUI.scala:62)
  at org.apache.spark.ui.WebUI$$anonfun$attachTab$1.apply(WebUI.scala:62)
  at  scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
  at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:47)
  at org.apache.spark.ui.WebUI.attachTab(WebUI.scala:62)
  at org.apache.spark.ui.SparkUI.initialize(SparkUI.scala:61)
  at org.apache.spark.ui.SparkUI.&lt;init&gt;(SparkUI.scala:74)
  at org.apache.spark.ui.SparkUI$.create(SparkUI.scala:190)
  at org.apache.spark.ui.SparkUI$.createLiveUI(SparkUI.scala:141)
  at org.apache.spark.SparkContext.&lt;init&gt;(SparkContext.scala:440)
  at org.apache.spark.api.java.JavaSparkContext.&lt;init&gt;(JavaSparkContext.scala:61)
  at tr.vedat.spark.SparkExample.main(SparkExample.java:24)
  15/07/20 14:44:42 INFO spark.MapOutputTrackerMasterEndpoint:       MapOutputTrackerMasterEndpoint stopped!
  15/07/20 14:44:42 ERROR spark.SparkContext: Error stopping SparkContext after init error.
  java.lang.NullPointerException
  at      
    org.apache.spark.network.netty.NettyBlockTransferService.close(NettyBlockTransfe   rService.scala:152)
  at org.apache.spark.storage.BlockManager.stop(BlockManager.scala:1214)
  at org.apache.spark.SparkEnv.stop(SparkEnv.scala:96)
  at org.apache.spark.SparkContext.stop(SparkContext.scala:1657)
  at org.apache.spark.SparkContext.&lt;init&gt;(SparkContext.scala:565)
  at org.apache.spark.api.java.JavaSparkContext.&lt;init&gt;(JavaSparkContext.scala:61)
  at tr.vedat.spark.SparkExample.main(SparkExample.java:24)
  Exception in thread "main" java.lang.SecurityException: class    "javax.servlet.FilterRegistration"'s signer information does not match signer information of other classes in the same package
  at java.lang.ClassLoader.checkCerts(ClassLoader.java:952)
  at java.lang.ClassLoader.preDefineClass(ClassLoader.java:666)
  at java.lang.ClassLoader.defineClass(ClassLoader.java:794)
  at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
  at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
  at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
  at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
  at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
  at org.spark-project.jetty.servlet.ServletContextHandler.&lt;init&gt;(ServletContextHandler.java:136)
  at org.spark-project.jetty.servlet.ServletContextHandler.&lt;init&gt;(ServletContextHandler.java:129)
  at org.spark-project.jetty.servlet.ServletContextHandler.&lt;init&gt;(ServletContextHandler.java:98)
  at org.apache.spark.ui.JettyUtils$.createServletHandler(JettyUtils.scala:108)
  at org.apache.spark.ui.JettyUtils$.createServletHandler(JettyUtils.scala:99)
  at org.apache.spark.ui.WebUI.attachPage(WebUI.scala:78)
  at org.apache.spark.ui.WebUI$$anonfun$attachTab$1.apply(WebUI.scala:62)
  at org.apache.spark.ui.WebUI$$anonfun$attachTab$1.apply(WebUI.scala:62)
  at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
  at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:47)
  at org.apache.spark.ui.WebUI.attachTab(WebUI.scala:62)
  at org.apache.spark.ui.SparkUI.initialize(SparkUI.scala:61)
  at org.apache.spark.ui.SparkUI.&lt;init&gt;(SparkUI.scala:74)
  at org.apache.spark.ui.SparkUI$.create(SparkUI.scala:190)
  at org.apache.spark.ui.SparkUI$.createLiveUI(SparkUI.scala:141)
  at org.apache.spark.SparkContext.&lt;init&gt;(SparkContext.scala:440)
  at org.apache.spark.api.java.JavaSparkContext.&lt;init&gt;(JavaSparkContext.scala:61)
  at tr.vedat.spark.SparkExample.main(SparkExample.java:24)
  </code></pre>
  
  <p>Here is my pom.xml </p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
  &lt;groupId&gt;tr.com.vedat&lt;/groupId&gt;
  &lt;artifactId&gt;aa&lt;/artifactId&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;packaging&gt;jar&lt;/packaging&gt;
  
  &lt;name&gt;aa&lt;/name&gt;
  &lt;url&gt;http://maven.apache.org&lt;/url&gt;
  
  &lt;properties&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
  &lt;/properties&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;junit&lt;/groupId&gt;
          &lt;artifactId&gt;junit&lt;/artifactId&gt;
          &lt;version&gt;3.8.1&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  
  
      &lt;dependency&gt;
          &lt;groupId&gt;ant&lt;/groupId&gt;
          &lt;artifactId&gt;ant&lt;/artifactId&gt;
          &lt;version&gt;1.6.5&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.hadoop&lt;/groupId&gt;
          &lt;artifactId&gt;hadoop-common&lt;/artifactId&gt;
          &lt;version&gt;2.6.0&lt;/version&gt;
          &lt;exclusions&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;org.eclipse.jetty&lt;/groupId&gt;
                  &lt;artifactId&gt;*&lt;/artifactId&gt;
              &lt;/exclusion&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
                  &lt;artifactId&gt;*&lt;/artifactId&gt;
              &lt;/exclusion&gt;
          &lt;/exclusions&gt;
  
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.hadoop&lt;/groupId&gt;
          &lt;artifactId&gt;hadoop-hdfs&lt;/artifactId&gt;
          &lt;version&gt;2.6.0&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.spark&lt;/groupId&gt;
          &lt;artifactId&gt;spark-core_2.10&lt;/artifactId&gt;
          &lt;version&gt;1.4.0&lt;/version&gt;
          &lt;exclusions&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;org.apache.hadoop&lt;/groupId&gt;
                  &lt;artifactId&gt;hadoop-client&lt;/artifactId&gt;
              &lt;/exclusion&gt;
          &lt;/exclusions&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.hadoop&lt;/groupId&gt;
          &lt;artifactId&gt;hadoop-mapreduce-client-app&lt;/artifactId&gt;
          &lt;version&gt;2.6.0&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.spark&lt;/groupId&gt;
          &lt;artifactId&gt;spark-mllib_2.10&lt;/artifactId&gt;
          &lt;version&gt;1.4.0&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.hadoop&lt;/groupId&gt;
          &lt;artifactId&gt;hadoop-core&lt;/artifactId&gt;
          &lt;version&gt;1.2.1&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;commons-cli&lt;/groupId&gt;
          &lt;artifactId&gt;commons-cli&lt;/artifactId&gt;
          &lt;version&gt;1.2&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;commons-configuration&lt;/groupId&gt;
          &lt;artifactId&gt;commons-configuration&lt;/artifactId&gt;
          &lt;version&gt;1.6&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;commons-httpclient&lt;/groupId&gt;
          &lt;artifactId&gt;commons-httpclient&lt;/artifactId&gt;
          &lt;version&gt;3.0.1&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.4&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;commons-logging&lt;/groupId&gt;
          &lt;artifactId&gt;commons-logging&lt;/artifactId&gt;
          &lt;version&gt;1.1.1&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;commons-logging&lt;/groupId&gt;
          &lt;artifactId&gt;commons-logging-api&lt;/artifactId&gt;
          &lt;version&gt;1.0.4&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.codehaus.jackson&lt;/groupId&gt;
          &lt;artifactId&gt;jackson-core-asl&lt;/artifactId&gt;
          &lt;version&gt;1.8.8&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.codehaus.jackson&lt;/groupId&gt;
          &lt;artifactId&gt;jackson-mapper-asl&lt;/artifactId&gt;
          &lt;version&gt;1.8.8&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.mongodb&lt;/groupId&gt;
          &lt;artifactId&gt;mongo-hadoop-core_1.0.0&lt;/artifactId&gt;
          &lt;version&gt;1.0.0-rc0&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.mongodb&lt;/groupId&gt;
          &lt;artifactId&gt;mongo-java-driver&lt;/artifactId&gt;
          &lt;version&gt;2.10.1&lt;/version&gt;
      &lt;/dependency&gt;
  
  &lt;/dependencies&gt;
  </code></pre>
  
  <p></p>
  
  <p>So, can anyone help me to show what I'm doing wrong? Why I'm getting this error?</p>