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

  • Home
  • SEARCH
  • 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 6387071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:06:23+00:00 2026-05-25T03:06:23+00:00

When I sbt run the following code, package com.example import java.io.ObjectInputStream import java.io.ObjectOutputStream import

  • 0

When I “sbt run” the following code,

package com.example

import java.io.ObjectInputStream
import java.io.ObjectOutputStream
import java.io.FileInputStream
import java.io.FileOutputStream

object SimpleFailure extends App {
  case class MyClass(a: String, b: Int, c: Double)

  def WriteObjectToFile[A](obj: A, filename: String) {
    val output = new ObjectOutputStream(new FileOutputStream(filename, false))
    output.writeObject(obj)
  }  

  def ReadObjectFromFile[A](filename: String)(implicit m: Manifest[A]): A = {
    val obj = new ObjectInputStream(new FileInputStream(filename)) readObject

    obj match {
      case a if m.erasure.isInstance(a) => a.asInstanceOf[A]
      case _ => { sys.error("Type not what was expected when reading from file") }
    }
  }

  val orig = MyClass("asdf", 42, 2.71)
  val filename = "%s/delete_me.spckl".format(System.getProperty("user.home"))

  WriteObjectToFile(List(orig), filename)

  val loaded = try {
    ReadObjectFromFile[List[MyClass]](filename)
  } catch { case e => e.printStackTrace; throw e }

  println(loaded(0))
}

I get the following exception:

java.lang.ClassNotFoundException: com.example.SimpleFailure$MyClass

However, I can run the code fine in Eclipse with the Scala plugin. Is this an SBT bug? Interestingly, the problem only comes up when wrapping MyClass in a List (see how “orig” is wrapped in a List in the WriteObjectToFile call). If I don’t wrap in a List, everything works fine.

  • 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-05-25T03:06:23+00:00Added an answer on May 25, 2026 at 3:06 am

    I was able to reproduce this too using sbt 0.10.1 and scalaVersion := "2.9.0-1". You should probably just report it on github or bring it up on the mailing list.

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

Sidebar

Related Questions

I have a Scalatra project with the following build.sbt organization := com.example name :=
default SBT log level is info (see http://code.google.com/p/simple-build-tool/wiki/RunningSbt ). How do I set it
Is there a way to tell sbt to package all needed libraries (scala-library.jar) into
I am building a simple Scala project with SBT 0.11. All the code files
When I run sbt interactively from a DOS shell or from a cygwin bash
I have tried to install SBT on my macbook. When I run it, it
I use SBT 0.10.0 . How do I download/retrieve project dependencies? For example, for
When I run my project for the first time during an SBT session, it
What's the easiest way to debug Scala code managed by sbt using IntelliJ's built-in
I have a weird problem where I cannot run aapt from an sbt command

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.