Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7828187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:14:54+00:00 2026-06-02T10:14:54+00:00

I’ve defined a custom input and output format over in XMLIO.scala : import scala.xml.Node

  • 0

I’ve defined a custom input and output format over in XMLIO.scala:

import scala.xml.Node
import org.apache.hadoop.lib.input.FileInputFormat
import org.apache.hadoop.lib.output.FileOutputFormat
import org.apache.hadoop.mapreduce.{ RecordReader, RecordWriter }
// ...
object XMLIO {
    class XMLInputFormat extends FileInputFormat[LongWritable, Node] { /*...*/ }
    class XMLRecordReader extends RecordReader[LongWritable, Node] { /*...*/ }
    class XMLOutputFormat extends FileOutputFormat[LongWritable, Node] { /*...*/ }
    class XMLRecordWriter extends RecordWriter[LongWritable, Node] { /*...*/ }
}

Which I’m trying to use for a job I’m defining over in Example.scala:

import XMLIO._
import org.apache.hadoop.conf.Configuration
import org.apache.hadoop.mapreduce.Job
object Example {
    @throws(classOf[Exception])
    def main( args : Array[String] ) {
        val job = new Job(new Configuration(), "")
        job setInputFormatClass classOf[XMLInputFormat]
    }
}

However, this is giving me a compiler error:

[ERROR] /path/to/Example.scala:8: error: type mismatch;
[INFO]  found   : java.lang.Class[XMLInputFormat](classOf[XMLInputFormat])
[INFO]  required: java.lang.Class[_ <: org.apache.hadoop.mapreduce.InputFormat]
[INFO]     job setInputFormatClass classOf[XMLInputFormat]
[INFO]                                    ^

Which seemed odd to me, given that XMLInputFormat is a subclass of FileInputFormat, which is a subclass of InputFormat.

Playing around a bit in the REPL, I found a weird workaround. If I create an instance of XMLInputFormat before I set the input format class, there’s no compiler error. That is, the following compiles fine:

import XMLIO._
import org.apache.hadoop.conf.Configuration
import org.apache.hadoop.mapreduce.Job
object Example {
    @throws(classOf[Exception])
    def main( args : Array[String] ) {
        val x = new XMLInputFormat()
        val job = new Job(new Configuration(), "")
        job setInputFormatClass classOf[XMLInputFormat]
    }
}

What’s going on here? Is there a fix for this that doesn’t seem like so much of a hack?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T10:14:58+00:00Added an answer on June 2, 2026 at 10:14 am

    Looks like this was a bug with scala 2.9.0 (which is what I was using). When I upgraded to scala 2.9.1, the problem went away.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm parsing an XML file, the creators of it stuck in a bunch social
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.