Spark application throws javax.servlet.FilterRegistration

Spark application throws javax.servlet.FilterRegistration

Asked on January 12, 2019 in Apache-spark.
Add Comment


  • 4 Answer(s)

    This issue could be solved by, When the class conflict comes about because HBase depends on org.mortbay.jetty, and Spark depends on org.eclipse.jetty. By excluding org.mortbay.jetty dependencies from HBase the problem can be solved.

    In the case of hadoop-common, SO we want to exclude javax.servlet from hadoop-common. I have a  With my sbt dependencies, working HBase/Spark setup set up be like:

    val clouderaVersion = "cdh5.2.0"
    val hadoopVersion = s"2.5.0-$clouderaVersion"
    val hbaseVersion = s"0.98.6-$clouderaVersion"
    val sparkVersion = s"1.1.0-$clouderaVersion"
     
    val hadoopCommon = "org.apache.hadoop" % "hadoop-common" % hadoopVersion % "provided" excludeAll ExclusionRule(organization = "javax.servlet")
    val hbaseCommon = "org.apache.hbase" % "hbase-common" % hbaseVersion % "provided"
    val hbaseClient = "org.apache.hbase" % "hbase-client" % hbaseVersion % "provided"
    val hbaseProtocol = "org.apache.hbase" % "hbase-protocol" % hbaseVersion % "provided"
    val hbaseHadoop2Compat = "org.apache.hbase" % "hbase-hadoop2-compat" % hbaseVersion % "provided"
    val hbaseServer = "org.apache.hbase" % "hbase-server" % hbaseVersion % "provided" excludeAll ExclusionRule(organization = "org.mortbay.jetty")
    val sparkCore = "org.apache.spark" %% "spark-core" % sparkVersion % "provided"
    val sparkStreaming = "org.apache.spark" %% "spark-streaming" % sparkVersion % "provided"
    val sparkStreamingKafka = "org.apache.spark" %% "spark-streaming-kafka" % sparkVersion exclude("org.apache.spark", "spark-streaming_2.10")
    
    Answered on January 12, 2019.
    Add Comment

    Here IntelliJ IDEA is used, Then the following below steps will be useful:

    • Here choose Open Module Settings by Right clicking the project root folder
    • choose Modules in the left navigation column  in the new window
    • select Dependencies tab and find Maven: javax.servlet:servlet-api:2.5 in the column rightmost
    • By pressing ALT+Down move this item to the bottom.

    This willbe helpful to solve the problem.

    Answered on January 12, 2019.
    Add Comment

    This could be very helpful and it works:

    libraryDependencies ++= Seq(
        "org.apache.spark" %% "spark-core" % sparkVersion.value % "provided",
        "org.apache.spark" %% "spark-sql" % sparkVersion.value % "provided",
        ....................................................................
    ).map(_.excludeAll(ExclusionRule(organization = "javax.servlet")))
    
    Answered on January 12, 2019.
    Add Comment

    When you use SBT, FilterRegistration class is present in 3.0 and also if you use JETTY Or Java 8 this JAR 2.5 it automatically adds as dependency,

    Fix: Servlet-api-2.5 JAR was the mess there, I resolved this issue by adding servlet-api-3.0 jar in dependencies,

     

    If you are running inside intellij, please check in project settings if you have two active modules (one for the project and another for sbt).

    Probably a problem while importing existing project.

    Answered 7 days ago.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.